25
25
branches :
26
26
- develop
27
27
issue_comment :
28
- types : [created, edited]
28
+ types : [ created, edited ]
29
29
30
30
# Global permissions:
31
31
permissions :
@@ -48,15 +48,24 @@ jobs:
48
48
steps :
49
49
# Exit if the user does not have write access to the repository:
50
50
- name : ' Exit if user does not have write access'
51
+ id : assert-write-access
52
+
51
53
# Pin action to full length commit SHA
52
54
uses : lannonbr/repo-permission-check-action@2bb8c89ba8bf115c4bfab344d6a6f442b24c9a1f # v2.0.2
53
55
with :
54
56
permission : ' write'
55
57
env :
56
58
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57
59
60
+ # Continue with subsequent steps even when this step fails in order to "pass" the job and not trigger failure e-mails/notifications:
61
+ continue-on-error : true
62
+
58
63
# Checkout the repository:
59
64
- name : ' Checkout repository'
65
+
66
+ # Only run this step if a user has write access:
67
+ if : steps.assert-write-access.outcome == 'success'
68
+
60
69
# Pin action to full length commit SHA
61
70
uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
62
71
with :
@@ -73,11 +82,16 @@ jobs:
73
82
# Extract commit message and issue comment metadata:
74
83
- name : ' Extract metadata'
75
84
id : extract-metadata
85
+
86
+ # Only run this step if a user has write access:
87
+ if : steps.assert-write-access.outcome == 'success'
88
+
76
89
# Pin action to full length commit SHA
77
90
uses : stdlib-js/metadata-action@3ccf68f24c51ae23470319e8e5619d539df8212b # v3.0.0
78
91
79
92
# Check the metadata for directives to send tweets:
80
93
- name : ' Send tweets'
94
+
81
95
# Pin action to full length commit SHA
82
96
uses : stdlib-js/metadata-tweet-action@8e9b688c86150797c1c7f60bc8f7c9a9a30e10fe # v2.0.0
83
97
with :
@@ -90,6 +104,10 @@ jobs:
90
104
# Check the metadata for directives to dispatch workflows:
91
105
- name : ' Check metadata for workflow dispatch directives'
92
106
id : check-workflow-dispatch
107
+
108
+ # Only run this step if a user has write access:
109
+ if : steps.assert-write-access.outcome == 'success'
110
+
93
111
run : |
94
112
inputs=$(echo '${{ steps.extract-metadata.outputs.metadata }}' | jq -c '.[] | select(.type | contains("workflow_dispatch"))')
95
113
if [ -n "$inputs" ]; then
@@ -104,9 +122,10 @@ jobs:
104
122
105
123
# Dispatch first found workflow (if applicable):
106
124
- name : ' Dispatch workflow with inputs'
125
+
107
126
# Pin action to full length commit SHA
108
127
uses : benc-uk/workflow-dispatch@25b02cc069be46d637e8fe2f1e8484008e9e9609 # v1.2.3
109
- if : steps.check-workflow-dispatch.outputs.dispatch == 'true'
128
+ if : ${{ steps.assert-write-access.outcome == 'success' && steps. check-workflow-dispatch.outputs.dispatch == 'true' }}
110
129
with :
111
130
workflow : ${{ steps.check-workflow-dispatch.outputs.workflow }}
112
131
inputs : ${{ steps.check-workflow-dispatch.outputs.inputs }}
0 commit comments