'Reusing github actions workflow
Here I want to create branch deployment pipeline. Deployment will be done on every pull request and we need to get a branch name, so that we call a workflow with that branch name. I have tried to do it in the following way, But it is giving an error.
on:
pull_request:
types: [opened, synchronize, reopened]
env:
WORKFLOW: 'bigelio/todo/.github/workflows/branch-deployment-serverless-deploy.yml@${{ github.head_ref }}'
deploy:
needs: [terraform]
uses: $WORKFLOW
secrets:
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}
The error I am getting in github is this
Invalid workflow file: .github/workflows/branch-deployment-workflow.yml#L198
invalid value workflow reference: no version specified
Solution 1:[1]
It doesn't work because env context is available on a runner, while uses is evaluated outside that context, before runner is scheduled/created.
You can try using gh cli with something like: gh workflow run triage.yml --ref my-branch.
Alternatively, you could see if Environments would suite your needs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | frennky |
