Skip to content

Dispatch

Dispatch #204

Workflow file for this run

name: Dispatch
on:
workflow_run:
workflows: ["Python package"]
branches: [master, dev]
types:
- completed
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Get current branch
id: get-branch
run: |
echo "##[set-output name=branch;]$(echo ${{github.event.workflow_run.head_branch}})"
- name: Trigger docker-stacks
run: |
GH_BRANCH=${{ steps.get-branch.outputs.branch }}
if [ "$GH_BRANCH" = "dev" ]
then
curl -XPOST -u "${{secrets.GH_USERNAME}}:${{secrets.GH_TOKEN}}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/digiklausur/docker-stacks/actions/workflows/manual-workflow.yml/dispatches --data '{"ref":"refs/heads/dev", "inputs":{"branch": "dev"}}'
echo "docker-stacks dev branch is dispatched"
elif [ "$GH_BRANCH" = "master" ]
then
curl -XPOST -u "${{secrets.GH_USERNAME}}:${{secrets.GH_TOKEN}}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/digiklausur/docker-stacks/actions/workflows/manual-workflow.yml/dispatches --data '{"ref":"refs/heads/master", "inputs":{"branch": "master"}}'
echo "docker-stacks master branch is dispatched"
else
echo "Nothing to dispatch. Only master and dev branches can dispatch build to docker-stacks"
fi
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Nothing to dispatch
run: |
echo "Linting or python build failed, nothing to dispatch"