Workflow: Triggering the workflow a different way with gh script
This commit is contained in:
127
.github/workflows/dispatcher.yml
vendored
127
.github/workflows/dispatcher.yml
vendored
@@ -3,70 +3,91 @@ name: Dispatcher
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**' # minden branchre lefut
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
detect-and-dispatch:
|
||||
runs-on: self-hosted # (sajat rpi-on fusson)
|
||||
|
||||
dispatch:
|
||||
runs-on: self-hosted
|
||||
outputs:
|
||||
engine: ${{ steps.check.outputs.engine }}
|
||||
server: ${{ steps.check.outputs.server }}
|
||||
ui: ${{ steps.check.outputs.ui }}
|
||||
steps:
|
||||
- name: Detect project from branch name
|
||||
id: detect
|
||||
- name: Determine which tests to run
|
||||
id: check
|
||||
run: |
|
||||
BRANCH_NAME=${GITHUB_REF##*/}
|
||||
echo "Branch name: $BRANCH_NAME"
|
||||
BRANCH="${{ github.ref_name }}"
|
||||
echo "Branch: $BRANCH"
|
||||
|
||||
if [[ "$BRANCH_NAME" == Engine/* ]]; then
|
||||
echo "project=Engine" >> $GITHUB_OUTPUT
|
||||
elif [[ "$BRANCH_NAME" == Server/* ]]; then
|
||||
echo "project=Server" >> $GITHUB_OUTPUT
|
||||
elif [[ "$BRANCH_NAME" == UI/* ]]; then
|
||||
echo "project=UI" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "project=unknown" >> $GITHUB_OUTPUT
|
||||
ENGINE=false
|
||||
SERVER=false
|
||||
UI=false
|
||||
|
||||
if [[ "$BRANCH" == *"Engine"* ]]; then
|
||||
ENGINE=true
|
||||
fi
|
||||
if [[ "$BRANCH" == *"Server"* ]]; then
|
||||
SERVER=true
|
||||
fi
|
||||
if [[ "$BRANCH" == *"UI"* ]]; then
|
||||
UI=true
|
||||
fi
|
||||
|
||||
# Run all on master
|
||||
if [[ "$BRANCH" == "master" ]]; then
|
||||
ENGINE=true
|
||||
SERVER=true
|
||||
UI=true
|
||||
fi
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
echo "engine=$ENGINE" >> $GITHUB_OUTPUT
|
||||
echo "server=$SERVER" >> $GITHUB_OUTPUT
|
||||
echo "ui=$UI" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Trigger Engine tests
|
||||
if: steps.detect.outputs.project == 'Engine'
|
||||
uses: peter-evans/workflow-dispatch@v2
|
||||
- name: Trigger Engine Test
|
||||
if: steps.check.outputs.engine == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
workflow: "engine_test.yml"
|
||||
ref: ${{ github.ref }}
|
||||
script: |
|
||||
github.rest.actions.createWorkflowDispatch({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
workflow_id: 'engine_test.yml',
|
||||
ref: '${{ github.ref }}',
|
||||
inputs: {
|
||||
triggered_by: 'dispatch.yml',
|
||||
branch: '${{ github.ref_name }}'
|
||||
}
|
||||
})
|
||||
|
||||
- name: Trigger Server tests
|
||||
if: steps.detect.outputs.project == 'Server'
|
||||
uses: peter-evans/workflow-dispatch@v2
|
||||
- name: Trigger Server Test
|
||||
if: steps.check.outputs.server == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
workflow: "server_test.yml"
|
||||
ref: ${{ github.ref }}
|
||||
script: |
|
||||
github.rest.actions.createWorkflowDispatch({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
workflow_id: 'server_test.yml',
|
||||
ref: '${{ github.ref }}',
|
||||
inputs: {
|
||||
triggered_by: 'dispatch.yml',
|
||||
branch: '${{ github.ref_name }}'
|
||||
}
|
||||
})
|
||||
|
||||
- name: Trigger UI tests
|
||||
if: steps.detect.outputs.project == 'UI'
|
||||
uses: peter-evans/workflow-dispatch@v2
|
||||
- name: Trigger UI Test
|
||||
if: steps.check.outputs.ui == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
workflow: "ui_test.yml"
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Trigger all tests (main/master)
|
||||
if: github.ref_name == 'main' || github.ref_name == 'master'
|
||||
uses: peter-evans/workflow-dispatch@v2
|
||||
with:
|
||||
workflow: "engine_test.yml"
|
||||
ref: ${{ github.ref }}
|
||||
- uses: peter-evans/workflow-dispatch@v2
|
||||
if: github.ref_name == 'main' || github.ref_name == 'master'
|
||||
with:
|
||||
workflow: "server_test.yml"
|
||||
ref: ${{ github.ref }}
|
||||
- uses: peter-evans/workflow-dispatch@v2
|
||||
if: github.ref_name == 'main' || github.ref_name == 'master'
|
||||
with:
|
||||
workflow: "ui_test.yml"
|
||||
ref: ${{ github.ref }}
|
||||
script: |
|
||||
github.rest.actions.createWorkflowDispatch({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
workflow_id: 'ui_test.yml',
|
||||
ref: '${{ github.ref }}',
|
||||
inputs: {
|
||||
triggered_by: 'dispatch.yml',
|
||||
branch: '${{ github.ref_name }}'
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user