Workflow can't seem to access organisation secret #202954
Replies: 2 comments 4 replies
|
The workflow itself doesn't look like the problem. The same That request is made by Since the build job successfully uploads the A few things I'd check:
One other thing I'd question is whether a PAT is needed here at all. The request is for artifacts from the same repository: In many cases, the default github-token: ${{ secrets.COZY_PAT }}with: github-token: ${{ github.token }}If that works, it points to a Based on the logs, this looks much more like a repository-specific authentication or secret configuration issue than a problem with |
|
With the full workflow, I do not think secrets: inherit is the problem. build-website and publish are reusable-workflow jobs within the same top-level Commit preview workflow run. The build job uploads html, and the publish job waits for it through needs: build-website. Therefore, download-artifact can download the artifact directly from the current run. The github-token and run-id inputs are only needed when downloading from a different workflow run or repository. Supplying COZY_PAT makes download-artifact use the authenticated GitHub API path, so the 401 is more likely related to the PAT than to artifact sharing. I would simplify publish-website.yaml to: jobs: You can also remove the run-id input, GITHUB_RUN_ID, the PAT validation step, and the custom GITHUB_TOKEN environment variable. Naming a PAT GITHUB_TOKEN is especially confusing because GitHub already provides a token with that name. Your existing caller configuration is correct: publish: secrets: inherit passes the caller's accessible organization and repository secrets into a directly called reusable workflow. Adding another repository to an organization secret's selected-repository policy after creating the secret should not require storing the secret value again. The Cozy PAT validation check is also a useful distinction: If that step ran, COZY_PAT was available and nonempty. The commit-comment job does not need the PAT either. peter-evans/commit-comment defaults to the workflow's github.token, current repository, and current commit SHA. The GitHub endpoint for creating a commit comment only requires contents: read, which you already grant. It can therefore be reduced to: comment-on-commit: env: steps: A PAT would only be necessary here when downloading an artifact from another repository or run, or when commenting in another repository. For a cross-run artifact download, the token needs Actions: read access to the target repository, and the repository and run-id inputs should identify that target explicitly. |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
💬 Feature/Topic Area
Workflow Configuration
Discussion Details
A few years ago, I built a GitHub Actions workflow to build and deploy a website. This has worked well, but when I copied the workflows over to a new site, they don't work and I can't figure out why.
Background
The build and deploy processes are both reusable workflows inside their own jobs:
The built website is uploaded as an artefact and then downloaded by the publish job:
secrets.COZY_PATis a Personal Access Token which has Repository and Actions read-and-write permissions for both repositories, though it was only granted permission for the new repository after the secret had been set. It's an organisation secret, so they both should be able to access it. However, in the new repository, theactions/download-artefactstep fails with a 401 error. Why would it work in one repository and not the other?All reactions