I’m working with a monorepo that has two separate GitHub Actions workflows and I need one to depend on the other.
First workflow - .github/workflows/ci.yml
:
name: ci
on: [push, pull_request]
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: execute tests
run: |
npm install
npm run test
Second workflow - .github/workflows/release.yml
:
name: release
on:
push:
tags:
- "v*"
jobs:
publish-release:
runs-on: ubuntu-latest
needs: run-tests
steps:
- uses: actions/checkout@v2
- name: publish release
run: |
npm run build
npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
The problem is I get this error when trying to reference a job from another workflow:
### ERROR 12:45:32Z
- Workflow file is invalid: Invalid workflow configuration. At least one job must exist without dependencies.
My goal: I want the CI workflow to run on all pushes and PRs, but when tags are pushed, I want the release workflow to only run after the CI workflow completes successfully. How can I make workflows depend on each other without duplicating jobs?