-
Notifications
You must be signed in to change notification settings - Fork 5
61 lines (54 loc) · 1.95 KB
/
trigger-preview.yml
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
name: trigger preview
on:
workflow_run:
workflows: ["trigger build"]
types: [completed]
jobs:
get-pr-number:
runs-on: ubuntu-latest
outputs:
PR_NUMBER: ${{ steps.get-pr-number.outputs.PR_NUMBER }}
SHA: ${{ steps.get-pr-number.outputs.SHA }}
steps:
- name: Download PR number artifact
uses: dawidd6/action-download-artifact@v6
with:
name: pr_number
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: trigger-build
run_id: ${{ github.event.workflow_run.id }}
- name: Read PR number
id: get-pr-number
run: |
tree .
cat pr_number.txt
{ read PR_NUMBER; read SHA; } < pr_number.txt
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "SHA=$SHA" >> $GITHUB_OUTPUT
make-or-find-preview-comment:
needs: get-pr-number
uses: './.github/workflows/preview-comment.yml'
with:
pr_number: ${{ needs.get-pr-number.outputs.PR_NUMBER }}
sha: ${{ needs.get-pr-number.outputs.SHA }}
no_update: 'true'
build-for-preview:
needs: get-pr-number
uses: './.github/workflows/build.yml'
with:
artifact_name: docs-zip-${{ needs.get-pr-number.outputs.PR_NUMBER }}
build_from_code_artifact: true
code_artifact_name: code-zip-${{ needs.get-pr-number.outputs.PR_NUMBER }}
deploy-preview:
needs: [get-pr-number, build-for-preview]
if: github.event.workflow_run.conclusion == 'success'
uses: './.github/workflows/gh-pages.yml'
with:
artifact_name: docs-zip-${{ needs.get-pr-number.outputs.PR_NUMBER }}
destination_dir: _preview/${{ needs.get-pr-number.outputs.PR_NUMBER }} # deploy to subdirectory labeled with PR number
preview-comment:
needs: [get-pr-number, deploy-preview, make-or-find-preview-comment]
uses: './.github/workflows/preview-comment.yml'
with:
pr_number: ${{ needs.get-pr-number.outputs.PR_NUMBER }}
sha: ${{ needs.get-pr-number.outputs.SHA }}