Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"{}" argument syntax in route does not work, ":" works #69

Closed
dzeyelid opened this issue Jan 23, 2021 · 6 comments
Closed

"{}" argument syntax in route does not work, ":" works #69

dzeyelid opened this issue Jan 23, 2021 · 6 comments

Comments

@dzeyelid
Copy link

The README shows sample codes with {} as an argument, but it does not work. The samples confuse users. I guess it's better to replace the syntax with :.

For example,

# This does not work

- uses: octokit/request-action@v2.x
  id: get_latest_release
  with:
    route: GET /repos/{owner}/{repo}/releases/latest
    owner: octokit
    repo: request-action
# This works

- uses: octokit/request-action@v2.x
  id: get_latest_release
  with:
    route: GET /repos/:owner/:repo/releases/latest
    owner: octokit
    repo: request-action

Anyway, thanks for this great action!

Best regards,

@gr2m
Copy link
Contributor

gr2m commented Jan 24, 2021

We run our tests using the {} notation, so I'm very sure that it works

- name: "Get latest release of ${{ github.repository }}"
uses: ./
id: get_latest_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: GET /repos/{owner}/{repo}/releases/latest
owner: octokit
repo: request-action

Here is the log from the latest test build:

https://github.com/octokit/request-action/runs/1746833106?check_suite_focus=true#step:7:62

What error are you getting?

@dzeyelid
Copy link
Author

Oh, I'm sorry. I tested once again to respond to you, I noticed my case was a particular one.

In summary, GET /repos/{owner}/{repo}/releases/latest works but GET /repos/{repo}/releases/latest does not work. GET /repos/:repo/releases/latest also works.

https://github.com/dzeyelid/github-actions-playground/blob/main/.github/workflows/test-octokit-request-action.yml#L60-L67

The reason why I wrote the code above that because I thought it's convenient to use the context ${{ github.repository }} to indicate repository. The context is a string like {owner}/{repo}.

The action log is here https://github.com/dzeyelid/github-actions-playground/runs/1759887820

@gr2m
Copy link
Contributor

gr2m commented Jan 25, 2021

There is a difference in encoding depending on whether you use : or {}. When using the {} notation, it correctly encodes the "/" character as per specification. When using : it does not, which is actually a bug, which in your case makes it work, but I would not depend on it. We will stop supporting : in a future version altogether.

I would recommend to use the two URL parameters GET /repos/{owner}/{repo}/releases/latest as it is documented. Alternatively you can use GET /repositories/{repository_id}/releases/latest which is an endpoint that exist, but is not currently documented.

@dzeyelid
Copy link
Author

@gr2m Thanks for explain detailly. I'll fix my code with {}.

(I hope split() function will be added to GitHub Actions built-in function.)

Anyway, I close this issue. Thanks so much!

@gr2m
Copy link
Contributor

gr2m commented Jan 26, 2021

GET /repos/{repo}/releases/latest should work again, via v2.0.26. Can you give it another try to confirm?

@dzeyelid
Copy link
Author

@gr2m Yes, I was able to see the result /repos/{repo}/releases/latest by checking my improved workflow. It's convenient. :)

The action log is here.
https://github.com/dzeyelid/github-actions-playground/runs/1766724662

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants