I'm looking for guidance on modifying my GitHub Actions workflow to trigger a job build automatically after the successful completion of a "validate" job. Currently, the workflow looks like the following:
validate.yml
name: Validate
on:
push:
branches: [ "DEVELOP" ]
tags:
- v**
pull_request:
branches: [ "DEVELOP" ]
tags:
- v**
jobs:
validate:
runs-on: ubuntu-latest
....
build.yml
name: Build
on:
workflow_run:
workflows:
- Validate
types:
- completed
workflow_dispatch:
jobs:
build:
name: Push to Docker image to GitHub
runs-on: ubuntu-latest
.....
I found the answer in the Git documents from here. I want the 'build' job to run after the 'validate' job successfully completes. Therefore, in the 'build' job, I need to check if the 'preview' job was successful before starting.
Answer:
on:
workflow_run:
workflows:
- Validate
types:
- completed
jobs:
build:
name: Push to Docker image to GitHub
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
....