forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.47 KB
/
docs-preview-deploy.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Preview Deploy
permissions:
contents: write
pull-requests: write
on:
workflow_run:
workflows:
- "Preview Build"
types:
- completed
# Since we use single_commit and force on the deploy action, only one deploy action can run at a time.
# Should this create a bottleneck we might have to set single_commit and force to false which should allow
# for the deployments to run in parallel.
concurrency:
group: preview_deploy
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: "Download build artifact"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: gateway_docs
path: gateway_docs_artifact
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: "Download build meta"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: meta.json
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Parse meta.json
run: |
echo "PR_NUMBER=$(jq -r .pr_number meta.json)" >> $GITHUB_ENV
echo "URL_SLUG=$(jq -r .url_slug meta.json)" >> $GITHUB_ENV
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: gateway_docs_artifact
repository-name: zirain/eg-pr-preview
branch: "main"
clean: true
target-folder: ${{ env.URL_SLUG }}
token: ${{ secrets.DEPLOY_PAT }}
commit-message: "Update preview for PR ${{ env.URL_SLUG }}"
single-commit: true
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Preview available at https://zirain.github.io/eg-pr-preview/${{ env.URL_SLUG }}
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.
pr_number: ${{ env.PR_NUMBER }}
comment_tag: "eg-preview"
# Add the 'docs-preview' label to the PR
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: ${{ env.PR_NUMBER }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['docs-preview']
})