Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
255 lines (255 loc) · 12.5 KB
/
Copy pathaction.yml
File metadata and controls
255 lines (255 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Projections
description: >-
Project the commit the job checked out (or, opted in, compare a pull request with its merge base) in CI, report each
projection in the job summary and upload them as an artifact
author: GitHub Next
branding:
icon: layers
color: purple
inputs:
trust:
description: >-
Pass --trust, allowing extractors that run repository code (custom commands and toolchain-based
built-ins). On pull requests this runs code from the pull request's head. Leave false unless every
projection you need requires it and the workflow has no secrets or write permissions.
default: 'false'
version:
description: >-
CLI release to install: a release tag such as v0.1.0, a major version such as v0 (its newest stable release), or
latest. Defaults to the action's own version tag (for @v0, v0's newest stable release), else latest.
default: ''
cli-repository:
description: Repository whose releases publish the CLI
default: githubnext/projections
compare:
description: >-
On pull requests, compare the merge base with the head (projections compare <merge-base>..<head> --definition
base) instead of projecting only the commit the job checked out. Runs Git to find the merge base, so the
checkout needs full history (actions/checkout with fetch-depth 0); snapshots then render both sides. Pushes always
project the pushed commit.
default: 'false'
reuse-base-artifact:
description: >-
With compare, reuse the merge base's own projections artifact (from the newest successful run of this workflow
file for that commit, for a push or a pull request from this repository, never a fork's) instead of extracting
the base again. The CLI verifies every reused extraction; without one, the base is extracted here, in a
workspace prepared by the repository's environment file when trust is true.
default: 'true'
build-from-source:
description: Build the CLI from the action's source instead of installing a release (needs Rust; for testing unreleased versions)
default: 'false'
working-directory:
description: The checkout to examine
default: '.'
artifact-name:
description: Actions artifact name
default: projections
retention-days:
description: Days to keep the artifact (0 uses the repository default)
default: '0'
attest:
description: >-
Attest the artifact's manifest (GitHub artifact attestations), so `projections --ci --artifact DIR` can
authenticate a downloaded copy as this repository's official CI output. Needs id-token: write and
attestations: write, and attestations available to the repository (public, or GitHub Enterprise Cloud). Skipped
on pull requests from forks, which can't attest.
default: 'false'
summary:
description: Write each projection's result, steps and changes to the job summary
default: 'true'
comment:
description: >-
Also post the summary as one pull request comment, updated on each run (needs pull-requests write). It reports
the comparison with compare, else the checked-out merge commit's projections.
default: 'false'
hosted-url:
description: >-
Origin of a hosted view of the uploaded artifact, such as https://projections.example, to link from the
summary and the comment. Empty links none.
default: ''
snapshots:
description: >-
Projection IDs (separated by commas, spaces or newlines) to render as PNG snapshots, light and dark, with the
real renderer in the runner's installed Chrome, Chromium or Edge (GitHub-hosted runners have Chrome). The
projected commit is rendered; only with compare are a pull request's merge base and head both rendered. The images
are uploaded as the <artifact-name>-snapshots artifact. Empty renders none.
default: ''
browser:
description: Chrome, Chromium or Edge executable for snapshots. Empty finds one on PATH or in its usual install location.
default: ''
browser-no-sandbox:
description: >-
Draw snapshots with the browser's sandbox off, for a job that runs as root (in a container, say), where Chrome
won't start with it. Custom renderers from the repository then run without the browser's process isolation, so
turn it on only where the job itself is isolated. 'true' turns it off; anything else keeps it.
default: 'false'
snapshots-commit:
description: >-
On pushes to the default branch, commit the snapshots to snapshots-path, for example to embed them in a README.
Skipped when they are unchanged or the branch moved on. Needs contents: write.
default: 'false'
snapshots-path:
description: Repository directory for committed snapshots (<id>.light.png and <id>.dark.png)
default: .github/projections/snapshots
snapshots-commit-message:
description: Commit message for snapshots-commit
default: Update Projections snapshots
snapshots-branch:
description: >-
On pull requests from this repository, commit the snapshots (with compare, before and after) to this dedicated
branch (created without history when missing) under pull/<number>/, so the comment can show them. Needs contents:
write. Empty, or a pull request from a fork, links the snapshots artifact instead.
default: ''
fail-on-error:
description: Fail the job when any projection fails. By default failures are reported per projection and the job succeeds.
default: 'false'
token:
description: Token for downloading and verifying the CLI release and for the comment
default: ${{ github.token }}
outputs:
directory:
description: The artifact directory
value: ${{ steps.collect.outputs.directory }}
manifest:
description: Path of projections.artifact.json
value: ${{ steps.collect.outputs.manifest }}
projections:
description: Number of projections
value: ${{ steps.collect.outputs.projections }}
failed:
description: Number of projections that failed
value: ${{ steps.collect.outputs.failed }}
artifact-id:
description: ID of the uploaded Actions artifact
value: ${{ steps.upload.outputs.artifact-id }}
attestation-url:
description: URL of the artifact manifest's attestation, when attest is true
value: ${{ steps.attest.outputs.attestation-url }}
cli-version:
description: The CLI's --version output
value: ${{ steps.install.outputs.cli-version }}
snapshots-directory:
description: The snapshots directory (PNG files and snapshots.json), when snapshots is set
value: ${{ steps.snapshots.outputs.directory }}
snapshots-artifact-id:
description: ID of the uploaded snapshots artifact
value: ${{ steps.upload-snapshots.outputs.artifact-id }}
snapshots-commit:
description: The commit holding the published snapshots, when they were committed
value: ${{ steps.publish-snapshots.outputs.commit }}
runs:
using: composite
steps:
- id: install
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_CLI_REPOSITORY: ${{ inputs.cli-repository }}
INPUT_BUILD_FROM_SOURCE: ${{ inputs.build-from-source }}
# The runner leaves GITHUB_ACTION_REF empty in a composite action's run steps; the expression has the ref.
ACTION_REF: ${{ github.action_ref }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/install.mjs"
# With compare, downloads the merge base's own artifact with the token; runs nothing from the repository.
- id: base
if: inputs.compare == 'true' && inputs.reuse-base-artifact == 'true'
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
INPUT_COMPARE: ${{ inputs.compare }}
INPUT_ARTIFACT_NAME: ${{ inputs.artifact-name }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/base.mjs"
- id: collect
shell: bash
env:
PROJECTIONS_CLI: ${{ steps.install.outputs.cli-path }}
PROJECTIONS_BASE_ARTIFACT: ${{ steps.base.outputs.directory }}
INPUT_TRUST: ${{ inputs.trust }}
INPUT_COMPARE: ${{ inputs.compare }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}
ACTION_REPOSITORY: ${{ github.action_repository }}
ACTION_REF: ${{ github.action_ref }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/collect.mjs"
- id: upload
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ inputs.artifact-name }}
path: ${{ steps.collect.outputs.directory }}
retention-days: ${{ inputs.retention-days }}
if-no-files-found: error
include-hidden-files: false
overwrite: true
# The manifest lists every document's SHA-256, so attesting it covers the artifact. A fork's pull request gets no
# id-token and isn't the repository's own CI output anyway.
- id: attest
if: >-
inputs.attest == 'true' && (github.event_name == 'push' || (github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository))
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: ${{ steps.collect.outputs.manifest }}
# Renders from the saved documents: no extractor runs again and no token is passed.
- id: snapshots
if: inputs.snapshots != ''
shell: bash
env:
PROJECTIONS_CLI: ${{ steps.install.outputs.cli-path }}
PROJECTIONS_MANIFEST: ${{ steps.collect.outputs.manifest }}
INPUT_TRUST: ${{ inputs.trust }}
INPUT_SNAPSHOTS: ${{ inputs.snapshots }}
INPUT_BROWSER: ${{ inputs.browser }}
INPUT_BROWSER_NO_SANDBOX: ${{ inputs.browser-no-sandbox }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/snapshot.mjs"
- id: upload-snapshots
if: steps.snapshots.outputs.count != '' && steps.snapshots.outputs.count != '0'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ inputs.artifact-name }}-snapshots
path: ${{ steps.snapshots.outputs.directory }}
retention-days: ${{ inputs.retention-days }}
if-no-files-found: error
include-hidden-files: false
overwrite: true
- id: publish-snapshots
if: steps.snapshots.outputs.count != '' && steps.snapshots.outputs.count != '0' && (inputs.snapshots-commit == 'true' || inputs.snapshots-branch != '')
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
PROJECTIONS_SNAPSHOTS: ${{ steps.snapshots.outputs.directory }}
INPUT_SNAPSHOTS_COMMIT: ${{ inputs.snapshots-commit }}
INPUT_SNAPSHOTS_PATH: ${{ inputs.snapshots-path }}
INPUT_SNAPSHOTS_COMMIT_MESSAGE: ${{ inputs.snapshots-commit-message }}
INPUT_SNAPSHOTS_BRANCH: ${{ inputs.snapshots-branch }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/publish.mjs"
# Reads the saved documents only; no token is passed.
- id: summary
if: inputs.summary == 'true'
shell: bash
env:
PROJECTIONS_MANIFEST: ${{ steps.collect.outputs.manifest }}
INPUT_HOSTED_URL: ${{ inputs.hosted-url }}
INPUT_ARTIFACT_NAME: ${{ inputs.artifact-name }}
PROJECTIONS_SNAPSHOTS: ${{ steps.snapshots.outputs.directory }}
PROJECTIONS_SNAPSHOT_IMAGES: ${{ steps.publish-snapshots.outputs.images }}
PROJECTIONS_SNAPSHOTS_ARTIFACT_URL: ${{ steps.upload-snapshots.outputs.artifact-url }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/summary.mjs"
- if: inputs.comment == 'true' && steps.collect.outputs.pull-request != ''
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
PROJECTIONS_MANIFEST: ${{ steps.collect.outputs.manifest }}
INPUT_HOSTED_URL: ${{ inputs.hosted-url }}
INPUT_ARTIFACT_NAME: ${{ inputs.artifact-name }}
PROJECTIONS_SNAPSHOTS: ${{ steps.snapshots.outputs.directory }}
PROJECTIONS_SNAPSHOT_IMAGES: ${{ steps.publish-snapshots.outputs.images }}
PROJECTIONS_SNAPSHOTS_ARTIFACT_URL: ${{ steps.upload-snapshots.outputs.artifact-url }}
run: node "$GITHUB_ACTION_PATH/packages/integrations/github-action/src/comment.mjs"
- if: inputs.fail-on-error == 'true' && steps.collect.outputs.failed != '0'
shell: bash
env:
FAILED: ${{ steps.collect.outputs.failed }}
run: |
echo "::error::$FAILED projection(s) failed; see the annotations above"
exit 1