Skip to content

tsukiy0's blog

Gated steps with GitHub Actions

October 20, 2020

The workflow_dispatch event allows us to manually trigger a build with given parameters.

  1. Add the deploy.sh script that will run in the pipeline

    if [ ${DEPLOY:-"false"} == "true" ]
    then
    echo "deploying!"
    fi
    • Will only deploy if DEPLOY is set to "true"
  2. Add the workflow_dispatch event to the pipeline .github/workflows/pipeline.yml

    name: pipeline
    on:
    push:
    branches:
    - master
    workflow_dispatch:
    inputs:
    deploy:
    description: deploy
    required: true
    default: "true"
    jobs:
    pipeline:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: deploy
    env:
    DEPLOY: ${{ github.event.inputs.deploy }}
    run: |
    sh ./deploy.sh
  3. Trigger the workflow_dispatch event through the UI

    GitHub UI for Triggering `workflow_dispatch`


tsukiy0