You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update token handling in artifact-manifest action (#822)
* created manifest action, README, and testing workflow
* fixed typos
* removed required:false as it is the default
* updated examples in README
* updated upload-artifact action to 7.0.1
* pared down comments in python script
* added input validation
* added duplicate detection for manually added artifacts
* added JSON validation logic
* replaced backticks with single quotes. removed action:write permissions.
* replaced backticks with simgle quotes. added masking to github token thats passed to the python script to prevent possibility of exposure in exception tracebacks
* updated README with examples
* testing masking
* changed method of passing the GH token. updated in all places
* pass the token ENV var to the script. update the README accordingly
* updated README
* updated README
* github_token now only required when fetching GHA artifacts
-**Paginated API handling**: Correctly handles runs with more than 100 artifacts
13
13
-**No external dependencies**: Pure Python standard library — no pip installs required
14
14
@@ -20,6 +20,8 @@ Add this step at the end of a build job, after all artifacts have been uploaded:
20
20
```yaml
21
21
- name: Upload artifact manifest
22
22
uses: bitwarden/gh-actions/artifact-manifest@main
23
+
env:
24
+
GITHUB_TOKEN: ${{ github.token }}
23
25
with:
24
26
mode: upload
25
27
gha_artifacts: |
@@ -40,7 +42,9 @@ Inputs:
40
42
- `mode`: Set to `upload`
41
43
- `gha_artifacts`: Newline-separated list of GHA artifact names that have been uploaded to the current run to include. Use `*` to include all artifacts from the run (the manifest itself is always excluded). Omit to include none.
42
44
- `additional_artifacts`: JSON object of non-GHA artifact entries to merge into the manifest. Keys are logical artifact names; values are type-specific objects.
43
-
- `github_token`: GitHub token used to query the run's artifact list. Defaults to `${{ github.token }}`.
45
+
46
+
Environment:
47
+
- `GITHUB_TOKEN`: GitHub token used to query the run's artifact list. **Required when using `gha_artifacts`.** Pass via `env: GITHUB_TOKEN: ${{ github.token }}`. Not required if using only `additional_artifacts`.
44
48
45
49
### Download Mode
46
50
Reference the manifest in a downstream workflow using the run ID from the upstream run:
@@ -49,6 +53,8 @@ Reference the manifest in a downstream workflow using the run ID from the upstre
49
53
- name: Download artifact manifest
50
54
id: manifest
51
55
uses: bitwarden/gh-actions/artifact-manifest@main
56
+
env:
57
+
GITHUB_TOKEN: ${{ github.token }}
52
58
with:
53
59
mode: download
54
60
run_id: ${{ github.event.workflow_run.id }}
@@ -68,7 +74,9 @@ Inputs:
68
74
- `mode`: Set to `download`
69
75
- `run_id`: The workflow run ID to download the manifest from. Required.
70
76
- `repo`: The `owner/repo` to download from. Defaults to the current repository.
71
-
- `github_token`: GitHub token with artifact read access. Defaults to `${{ github.token }}`.
77
+
78
+
Environment:
79
+
- `GITHUB_TOKEN`: GitHub token with artifact read access. **Required.** Pass via `env: GITHUB_TOKEN: ${{ github.token }}`. For cross-repo downloads, use a GitHub App token with `actions: read` permission on the target repository.
72
80
73
81
Outputs:
74
82
- `manifest`: The full manifest as a JSON string, accessible via `${{ steps.<step-id>.outputs.manifest }}`. Also available in upload mode.
@@ -81,6 +89,29 @@ Outputs:
81
89
run: echo "$IMAGE_SHA"
82
90
```
83
91
92
+
### Using Custom Tokens
93
+
94
+
For cross-repo artifact downloads, use a GitHub App token passed via the `env` parameter:
@@ -234,7 +275,7 @@ Provided via `additional_artifacts`. The `type` field is required; all other fie
234
275
- Python 3.6 or later must be available on the runner (present by default on GitHub-hosted runners)
235
276
- For `upload` mode, the GitHub token must have `actions: read` permission to query the run artifacts from the GitHub API
236
277
- The `gh` CLI must be available on the runner for download mode (present by default on GitHub-hosted runners)
237
-
- In `download` mode, for cross-repo downloads, the token must have `actions: read` on the target repository — the default `github.token` is scoped to the current repository only and will not work
278
+
- In `download` mode, for cross-repo downloads, use a GitHub App token with `actions: read` on the target repository — the default `GITHUB_TOKEN` is scoped to the current repository only
238
279
239
280
## Troubleshooting
240
281
@@ -258,3 +299,8 @@ Provided via `additional_artifacts`. The `type` field is required; all other fie
258
299
- Confirm the upstream run completed successfully and the manifest was uploaded
259
300
- Verify `repo` points to the correct repository if downloading cross-repo
260
301
- The artifact is uploaded under the name `artifact-manifest` — it must not have been deleted or expired
302
+
303
+
### "GITHUB_TOKEN environment variable is required when using gha_artifacts"
304
+
- This error occurs in upload mode when `gha_artifacts` is specified but `GITHUB_TOKEN` is not set
305
+
- Confirm that the `GITHUB_TOKEN` environment variable is set in an `env:` block: `env: GITHUB_TOKEN: ${{ github.token }}`
306
+
- If using only `additional_artifacts` (no `gha_artifacts`), the token is not required
0 commit comments