-
-
Notifications
You must be signed in to change notification settings - Fork 229
96 lines (85 loc) · 2.85 KB
/
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Deploy 🏗️
on:
workflow_run:
workflows:
- Quality checks 👌🧪
- Unstable release 🪲📦
types:
- completed
jobs:
cf-pages:
name: CloudFlare Pages 📃
runs-on: ubuntu-latest
outputs:
url: ${{ steps.cf.outputs.url }}
steps:
- name: Download workflow artifact ⬇️
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.JF_BOT_TOKEN }}
name: frontend
path: dist
- name: Publish to Cloudflare Pages 📃
uses: cloudflare/[email protected]
id: cf
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: jf-vue
directory: dist
branch: ${{ github.event.workflow_run.head_branch }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
pr-context:
name: Get PR context
if: ${{ always() && github.event.workflow_run.event == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
commit: ${{ env.pr_sha }}
pr_number: ${{ env.pr_number }}
steps:
- name: Get PR context ⬇️
uses: actions/download-artifact@v4
id: pr_context
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.JF_BOT_TOKEN }}
name: PR_context
- name: Set PR context environment variables
if: ${{ steps.pr_context.conclusion == 'success' }}
run: |
echo "pr_number=$(cat PR_number)" >> $GITHUB_ENV
echo "pr_sha=$(cat PR_sha)" >> $GITHUB_ENV
compose-comment:
name: Compose comment
if: ${{ always() }}
uses: ./.github/workflows/job_messages.yml
needs:
- cf-pages
- pr-context
with:
branch: ${{ github.event.workflow_run.head_branch }}
commit: ${{ needs.pr-context.outputs.commit != '' && needs.pr-context.outputs.commit || github.event.workflow_run.head_sha }}
preview_url: ${{ needs.cf-pages.outputs.url }}
build_workflow_run_id: ${{ github.event.workflow_run.id }}
commenting_workflow_run_id: ${{ github.run_id }}
in_progress: false
comment-status:
name: Create comment status
if: |
always() &&
github.event.workflow_run.event == 'pull_request' &&
needs.pr-context.outputs.pr_number != ''
runs-on: ubuntu-latest
needs:
- compose-comment
- pr-context
steps:
- name: Update job summary in PR comment
uses: thollander/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
message: ${{ needs.compose-comment.outputs.msg }}
pr_number: ${{ needs.pr-context.outputs.pr_number }}
comment_tag: ${{ needs.compose-comment.outputs.marker }}
mode: recreate