16
16
description : Name of the branch that it's being deployed
17
17
required : true
18
18
type : string
19
+ commit_id :
20
+ description : Commit ID that triggered the workflow
21
+ required : true
22
+ type : string
19
23
20
24
jobs :
21
25
cf-pages :
22
26
name : CloudFlare Pages 📃
23
27
runs-on : ubuntu-latest
24
- if : ${{ (inputs.workflow_run_id && inputs.branch) || github.event.workflow_run.conclusion == 'success' }}
28
+ if : ${{ (inputs.workflow_run_id != '' && inputs.branch != '' && inputs.commit_id != '' ) || github.event.workflow_run.conclusion == 'success' }}
25
29
26
30
steps :
27
31
- name : Download workflow artifact ⬇️
28
32
29
33
with :
30
- run_id : ${{ inputs.workflow_run_id || github.event.workflow_run.id }}
34
+ run_id : ${{ inputs.workflow_run_id != '' && inputs.workflow_run_id || github.event.workflow_run.id }}
31
35
name : frontend
32
36
path : dist
33
37
@@ -39,10 +43,63 @@ jobs:
39
43
accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
40
44
projectName : jf-vue
41
45
directory : dist
42
- branch : ${{ inputs.branch || github.event.workflow_run.head_branch }}
46
+ branch : ${{ inputs.branch != '' && inputs.branch || github.event.workflow_run.head_branch }}
43
47
gitHubToken : ${{ secrets.GITHUB_TOKEN }}
44
48
45
- - name : Create job summary 📖
49
+ - name : Create job summary and add to environment
50
+ id : msg
51
+ env :
52
+ COMMIT : ${{ inputs.commit_id != '' && inputs.commit_id || github.event.workflow_run.head_commit.id }}
53
+ BRANCH_URL : https://${{ inputs.branch != '' && inputs.branch || github.event.workflow_run.head_branch }}.jf-vue.pages.dev
46
54
run : |
47
- echo '# CloudFlare Pages deployment' >> $GITHUB_STEP_SUMMARY
48
- echo '${{ steps.cf.outputs.url }}' >> $GITHUB_STEP_SUMMARY
55
+ echo -e '## Cloudflare Pages deployment' > $GITHUB_STEP_SUMMARY
56
+ echo -e '\n' >> $GITHUB_STEP_SUMMARY
57
+ echo '| **Latest commit** | <code>$COMMIT</code |' >> $GITHUB_STEP_SUMMARY
58
+ echo '|------------------------- |:----------------------------: |' >> $GITHUB_STEP_SUMMARY
59
+ echo '| **Status** | ✅ Deployed! |' >> $GITHUB_STEP_SUMMARY
60
+ echo '| **Preview URL** | ${{ steps.cf.outputs.url }} |' >> $GITHUB_STEP_SUMMARY
61
+ echo '| **Branch Preview URL:** | $BRANCH_URL |' >> $GITHUB_STEP_SUMMARY
62
+ echo -e '\n' >> $GITHUB_STEP_SUMMARY
63
+ echo '<!--- CFPages deployment marker --->' >> $GITHUB_STEP_SUMMARY
64
+ COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
65
+ echo "msg=$COMPOSED_MSG" >> $GITHUB_ENV
66
+
67
+ - name : Update CF Pages deployment comment
68
+ uses :
thollander/[email protected]
69
+ with :
70
+ GITHUB_TOKEN : ${{ secrets.JF_BOT_TOKEN }}
71
+ message : ${{ env.msg }}
72
+ pr_number : ${{ github.event.workflow_run.pull_requests[0].number }}
73
+ comment_includes : ' <!--- CFPages deployment marker --->'
74
+
75
+ comment :
76
+ name : Update system comment status
77
+ runs-on : ubuntu-latest
78
+ if : ${{ github.event.workflow_run.conclusion != 'success' || failure() }}
79
+
80
+ steps :
81
+ - name : Create job summary and add to environment
82
+ id : msg
83
+ env :
84
+ COMMIT : ${{ github.event.workflow_run.head_commit.id }}
85
+ BRANCH_URL : https://${{ github.event.workflow_run.head_branch }}.jf-vue.pages.dev
86
+ run : |
87
+ echo -e '## Cloudflare Pages deployment' > $GITHUB_STEP_SUMMARY
88
+ echo -e '\n' >> $GITHUB_STEP_SUMMARY
89
+ echo '| **Latest commit** | <code>$COMMIT</code> |' >> $GITHUB_STEP_SUMMARY
90
+ echo '|------------------------- |:----------------------------: |' >> $GITHUB_STEP_SUMMARY
91
+ echo '| **Status** | ❌ Failure. Check workflow logs for more info |' >> $GITHUB_STEP_SUMMARY
92
+ echo '| **Preview URL** | Not available |' >> $GITHUB_STEP_SUMMARY
93
+ echo '| **Branch Preview URL:** | $BRANCH_URL |' >> $GITHUB_STEP_SUMMARY
94
+ echo -e '\n' >> $GITHUB_STEP_SUMMARY
95
+ echo '<!--- CFPages deployment marker --->' >> $GITHUB_STEP_SUMMARY
96
+ COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
97
+ echo "msg=$COMPOSED_MSG" >> $GITHUB_ENV
98
+
99
+ - name : Update CF Pages deployment comment
100
+ uses :
thollander/[email protected]
101
+ with :
102
+ GITHUB_TOKEN : ${{ secrets.JF_BOT_TOKEN }}
103
+ message : ${{ env.msg }}
104
+ pr_number : ${{ github.event.workflow_run.pull_requests[0].number }}
105
+ comment_includes : ' <!--- CFPages deployment marker --->'
0 commit comments