Skip to content

Commit

Permalink
Update workflow_dispatch API call
Browse files Browse the repository at this point in the history
* Add new triggers for tests
* Update actions url
* Update API call
* Add URL to Github docs
  • Loading branch information
mego22 committed Aug 6, 2024
1 parent 65e6425 commit 6944b97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ on:
- master
push:

workflow_dispatch:

# 11pm UTC; 7/8am EST/EDT
schedule:
- cron: '0 11 * * *'

jobs:
test_action:

runs-on: ubuntu-latest

steps:
- name: Trigger pipeline
uses: mego22/actions-workflow-pipeline@post-data
uses: mego22/actions-workflow-pipeline@fix-update-workflow_dispatch-call
with:
token: "${{ secrets.TOKEN }}"
dispatch: '[{"org": "mego22" ,"repo": "actions-workflow-pipeline", "branch": "main", "workflow": "trigger1.yml"},
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# actions-workflow-pipeline
Trigger additional workflows

Github docs for the action:
https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event

## Usage
### Trigger one or more workflows
```
Expand Down
8 changes: 5 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ check_commands() {
}


# https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
trigger_dispatches() {
for dispatch in `echo "${DISPATCHES}" | jq -c .[]`
do
Expand All @@ -39,10 +40,11 @@ EOF
echo "Triggering $WORKFLOW for $REPO."
echo "::endgroup::"

curl -qs \
curl -L \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GIT_TOKEN}" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GIT_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${WORKFLOW}/dispatches \
-d "$(_post_data)"

Expand Down

0 comments on commit 6944b97

Please sign in to comment.