Repository navigation
66 lines (62 loc) · 2.94 KB
/
Copy pathpreview.yml
File metadata and controls
66 lines (62 loc) · 2.94 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
name: Preview content
on:
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
preview:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
MERGE_REF: refs/pull/${{ github.event.pull_request.number }}/merge
steps:
- name: Check out trusted tooling
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: ${{ env.BASE_SHA }}
path: trusted
persist-credentials: false
- name: Check out submission as data
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: ${{ env.MERGE_REF }}
path: submission
persist-credentials: false
- name: Use Node.js 20
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 20
cache: npm
cache-dependency-path: trusted/package-lock.json
- name: Install trusted dependencies
working-directory: trusted
run: npm ci --ignore-scripts
- name: Build content contribution preview with trusted tooling
if: ${{ github.event.pull_request.head.repo.full_name != github.repository || !contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) }}
run: node trusted/scripts/build-preview.mjs --root submission --contract-root trusted --out-dir artifacts/preview
- name: Install proposed dependencies
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) }}
working-directory: submission
run: npm ci --ignore-scripts
- name: Build preview with proposed infrastructure
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) }}
run: node submission/scripts/build-preview.mjs --root submission --contract-root submission --out-dir artifacts/preview
- name: Upload preview artifact
id: preview-artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: cookbook-preview-${{ github.event.pull_request.number }}
path: artifacts/preview
retention-days: 3
if-no-files-found: error
- name: Add preview to job summary
env:
ARTIFACT_URL: ${{ steps.preview-artifact.outputs.artifact-url }}
run: |
printf '## Cookbook preview\n\nDownload the trusted static preview artifact: [%s](%s)\n' "cookbook-preview-${{ github.event.pull_request.number }}" "$ARTIFACT_URL" >> "$GITHUB_STEP_SUMMARY"