Skip to content

Commit 9f5b74a

Browse files
committed
Allow workflow_dispatch via metadata comments
1 parent 3d41af1 commit 9f5b74a

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

.github/workflows/process_metadata.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ on:
2424
push:
2525
branches:
2626
- develop
27+
issue_comment:
28+
types: [created, edited]
2729

2830
# Workflow jobs:
2931
jobs:
3032

31-
# Define a job for processing commit message metadata...
33+
# Define a job for processing commit message and issue comment metadata...
3234
process:
3335

3436
# Define a display name:
@@ -53,12 +55,12 @@ jobs:
5355
lfs: false
5456
timeout-minutes: 10
5557

56-
# Extract commit message metadata:
58+
# Extract commit message and issue comment metadata:
5759
- name: 'Extract metadata'
5860
id: extract-metadata
59-
uses: stdlib-js/commit-metadata-action@v1
61+
uses: stdlib-js/metadata-action@v2
6062

61-
# Check the commit message metadata for directives to send tweets:
63+
# Check the metadata for directives to send tweets:
6264
- name: 'Send tweets'
6365
uses: stdlib-js/metadata-tweet-action@v1
6466
with:
@@ -67,3 +69,25 @@ jobs:
6769
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
6870
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
6971
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
72+
73+
# Check the metadata for directives to dispatch workflows:
74+
- name: 'Check metadata for workflow dispatch directives'
75+
id: check-workflow-dispatch
76+
run: |
77+
inputs=$(echo ${{ steps.extract-metadata.outputs.metadata }} | jq -c '.[] | select(.type | contains("workflow_dispatch")) | first')
78+
name=$(echo $inputs | jq -r '.name')
79+
if [ -n "$inputs" ]; then
80+
echo "inputs=$inputs" >> $GITHUB_OUTPUT
81+
echo "workflow=$name" >> $GITHUB_OUTPUT
82+
echo "dispatch=true" >> $GITHUB_OUTPUT
83+
else
84+
echo "dispatch=false" >> $GITHUB_OUTPUT
85+
fi
86+
87+
# Dispatch first found workflow (if applicable):
88+
- name: 'Dispatch workflow with inputs'
89+
uses: benc-uk/workflow-dispatch@v1
90+
if: steps.check-workflow-dispatch.outputs.dispatch == 'true'
91+
with:
92+
workflow: ${{ steps.check-workflow-dispatch.outputs.workflow }}
93+
inputs: ${{ steps.check-workflow-dispatch.outputs.inputs }}

0 commit comments

Comments
 (0)