Skip to content

Commit

Permalink
fix: workflow should reference follow-on workflows on triggering branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-monninger committed Nov 29, 2023
1 parent 775a140 commit 14fb7c2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/actions/trigger-workflow/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Trigger Workflow'
description: 'Triggers another GitHub Actions workflow; useful for ensuring the workflow runs based off of the appropriate branch.'

inputs:
token:
description: 'Personal Access Token (PAT) with permissions to trigger workflows'
required: true
workflowFileName:
description: 'The file name of the workflow to trigger'
required: true
workflowInputs:
description: 'Inputs for the triggered workflow in JSON format'
required: false
default: '{}'

runs:
using: 'composite'
steps:
- name: Trigger another workflow
run: |
curl \
-X POST \
-H "Authorization: token ${{ inputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ inputs.workflowFileName }}/dispatches \
-d '{"ref":"${{ github.ref_name }}", "inputs": ${{ inputs.workflowInputs }}}'
shell: bash
10 changes: 10 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ jobs:
working-directory: ./m1
run: cargo check

tigger-test:
needs: check
runs-on: ubuntu-latest
steps:

- name: Trigger test
uses: ./github/actions/trigger-workflow
with:
workflowFileName: test.yml
token: ${{ secrets.CI_PAT }}
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Cargo Test

on:
workflow_run:
workflows: ["Cargo Check"]
types:
- completed
workflow_dispatch:

jobs:
test:
Expand Down

0 comments on commit 14fb7c2

Please sign in to comment.