Skip to content

Merge branch 'git-commit-push-action-12367624468-windows-full-remote'… #4528

Merge branch 'git-commit-push-action-12367624468-windows-full-remote'…

Merge branch 'git-commit-push-action-12367624468-windows-full-remote'… #4528

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}}"