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

Using GITHUB_TOKEN for Pandoc nightly download #868

Closed
cderv opened this issue Jun 14, 2024 · 2 comments · Fixed by #889
Closed

Using GITHUB_TOKEN for Pandoc nightly download #868

cderv opened this issue Jun 14, 2024 · 2 comments · Fixed by #889
Labels
bug an unexpected problem or unintended behavior

Comments

@cderv
Copy link
Contributor

cderv commented Jun 14, 2024

Not sure what changed, but I recently get pandoc nightly download to fail. Here is the debug logging

##[debug]Evaluating condition for step: 'Run r-lib/actions/setup-pandoc@v2'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run r-lib/actions/setup-pandoc@v[2](https://github.com/rstudio/rmarkdown/actions/runs/9518128513/job/26246875020#step:7:2)
##[debug]Loading inputs
##[debug]Evaluating: matrix.config.pandoc
##[debug]Evaluating Index:
##[debug]..Evaluating Index:
##[debug]....Evaluating matrix:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'config'
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'pandoc'
##[debug]=> 'nightly'
##[debug]Result: 'nightly'
##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run r-lib/actions/setup-pandoc@v2
##[debug]got pandoc-version nightly
##[debug]Downloading https://api.github.com/repos/jgm/pandoc/actions/artifacts/1601[3](https://github.com/rstudio/rmarkdown/actions/runs/9518128513/job/26246875020#step:7:3)04781/zip
##[debug]Destination /home/runner/work/_temp/03[4](https://github.com/rstudio/rmarkdown/actions/runs/9518128513/job/26246875020#step:7:4)2ed2d-f740-41f0-9e4e-6c0c29[5](https://github.com/rstudio/rmarkdown/actions/runs/9518128513/job/26246875020#step:7:5)66afb
##[debug]Failed to download from "https://api.github.com/repos/jgm/pandoc/actions/artifacts/1[6](https://github.com/rstudio/rmarkdown/actions/runs/9518128513/job/26246875020#step:7:6)01304781/zip". Code(403) Message(Forbidden)
Error: Failed to download Pandoc nightly build: Error: Unexpected HTTP response: 403
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run r-lib/actions/setup-pandoc@v2

from https://github.com/rstudio/rmarkdown/actions/runs/9518128513/job/26246875020#step:7:47

I am wondering if the token input is correctly passed to the API call 🤔

GITHUB_TOKEN Permissions
  Actions: read
  • If I call the URL using gh CLI locally it works gh api /repos/jgm/pandoc/actions/artifacts/1601304781/zip > nightly.zip

I don't know a lot about @action/core but I see we do this for nightly

const octokit = new Octokit();

and so we create octokit without the GITHUB_TOKEN.

There is a function to get Auth Header

function getAuthHeaderValue(): `Bearer ${string}` | undefined {
const authToken =
core.getInput("token", {
required: false,
trimWhitespace: true,
}) ?? undefined;
return !!authToken ? `Bearer ${authToken}` : undefined;
}

but it is not used in the script... So I wonder.

Is token input really used ? Or should we authenticate another way ?

I have seen in https://github.com/octokit/action.js/ that maybe setting GITHUB_TOKEN env could work so trying that now.
rstudio/rmarkdown#2559

@cderv
Copy link
Contributor Author

cderv commented Jun 14, 2024

🤔 I got this when adding env

Error: [@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth

So possibly with.token was already taken into account.

cderv added a commit to rstudio/rmarkdown that referenced this issue Jul 2, 2024
Revert to using own custom action waiting for r-lib/actions#868 to be fixed
cderv added a commit to rstudio/bookdown that referenced this issue Jul 2, 2024
yihui pushed a commit to rstudio/bookdown that referenced this issue Jul 2, 2024
gaborcsardi added a commit that referenced this issue Jul 31, 2024
This is now needed, apparently.

Closes #868.
@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Jul 31, 2024
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants