Update file(s) "/." from "GuillaumeFalourd/useful-actions" #2906
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test 18 #https://stackoverflow.com/questions/70326569/github-workflow-how-to-conditionally-setup-env-for-all-subsequent-jobs | |
on: | |
workflow_dispatch: | |
push: | |
jobs: | |
setup-job: | |
runs-on: ubuntu-latest | |
outputs: | |
var1: ${{ steps.set-variable.outputs.test }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set test variable | |
id: set-variable | |
run: | | |
if [ ${{ github.ref }} != 'refs/heads/main' ]; then | |
echo "IS NOT main branch" | |
echo "test=abc" >> $GITHUB_ENV | |
echo "::set-output name=test::abc" | |
else | |
echo "IS main branch" | |
echo "test=123" >> $GITHUB_ENV | |
echo "::set-output name=test::123" | |
fi | |
shell: bash | |
- name: Read exported variable | |
run: | | |
echo "ENV: ${{ env.test }}" | |
echo "OUTPUT: ${{ steps.check.test-env.test }}" | |
subsequent-job: | |
runs-on: ubuntu-latest | |
needs: [setup-job] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Read exported variable | |
run: | | |
echo "ENV: ${{ env.test }}" | |
echo "OUTPUT: ${{needs.setup-job.outputs.var1}}" |