-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (73 loc) · 2.39 KB
/
testenv.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: "test-env"
on:
workflow_dispatch:
jobs:
preprare:
name: Collect environment name from branch name
runs-on: ubuntu-latest
steps:
- name: Some check on branch
id: branch_check
run: |
echo "Running on branch ${{ github.ref }}"
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
echo "{env_name}={PROD}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" = "refs/heads/production" ]; then
echo "{env_name}={PROD}" >> $GITHUB_OUTPUT
echo "::set-output name=env_name::DEV"
elif [ "${{ github.ref }}" = "refs/heads/staging" ]; then
echo "::set-output name=env_name::QA"
elif [ "${{ github.ref }}" = "refs/heads/development" ]; then
echo "::set-output name=env_name::DEV"
else
echo "::set-output name=env_name::DEV"
fi
job1:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.step1.outputs.test }}
output2: ${{ steps.step2.outputs.test }}
steps:
- id: step1
run: echo "test=hello" >> "$GITHUB_OUTPUT"
- id: step2
run: echo "test=world" >> "$GITHUB_OUTPUT"
job2:
runs-on: ubuntu-latest
needs: job1
steps:
- env:
OUTPUT1: ${{needs.job1.outputs.output1}}
OUTPUT2: ${{needs.job1.outputs.output2}}
run: echo "$OUTPUT1 $OUTPUT2"
- name: Use variable setup in previous step
run: echo "I'm using variable ${{ steps.branch_check.outputs.env_name }}"
outputs:
env_name: ${{ steps.branch_check.outputs.env_name }}
# validate:
# needs: [ preprare ]
# runs-on: ubuntu-latest
# environment:
# name: ${{ needs.preprare.outputs.env_name }}
# name: "Printing previous step output"
# steps:
# - name: Extract branch name
# shell: bash
# run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
# id: extract_branch
# - name: echo
# shell: bash
# run: |
# echo "HOME: ${HOME}"
# echo "GITHUB_WORKFLOW: ${GITHUB_WORKFLOW}"
# echo "GITHUB_REF_NAME: ${GITHUB_REF_NAME}"
# echo "TEST_VALUE: ${TEST}"
# echo "TEST_1 TEST_VALUE: ${TEST_1}"
# env:
# TEST: ${{ vars.TEST }}
# TEST_1: ${{ needs.preprare.outputs.env_name }}
# - name: Checkout
# uses: actions/checkout@v3
# - name: Terraform validate
# uses: dflook/terraform-validate@v1
# id: validate