-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (101 loc) · 3.23 KB
/
test-index.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
on:
push:
branches:
- main
- development/*
pull_request:
branches:
- development/*
- main
workflow_dispatch:
inputs:
environment:
type: environment
default: production
name: test-index
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
jobs:
setup:
runs-on: ubuntu-latest
environment: ${{ inputs.environment || 'production' }}
outputs:
name: ${{ steps.artifacts.outputs.name }}
branch: ${{ steps.index.outputs.branch }}
shortcommit: ${{ steps.index.outputs.shortcommit }}
sha: ${{ steps.index.outputs.sha }}
actor: ${{ steps.index.outputs.actor }}
steps:
- uses: actions/checkout@v3
- name: Setup final status file
run: echo -n SUCCESSFUL > .final_status
- name: Push final status
id: artifacts
uses: ./
with:
url: ${{ vars.ARTIFACTS_URL }}
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: ./.final_status
method: upload
- name: Setup version
uses: ./
with:
method: index
url: ${{ vars.ARTIFACTS_URL }}
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
args: |
version=1.0.0-${{ github.run_number }}
- name: Setup index outputs
id: index
run: |
echo "branch=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_OUTPUT
if [[ ${{ github.event_name }} == "pull_request" ]]; then
SHA=${{ github.event.pull_request.head.sha }}
echo "sha=$SHA" >> $GITHUB_OUTPUT
echo "shortcommit=${SHA::10}" >> $GITHUB_OUTPUT
else
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "shortcommit=${GITHUB_SHA::10}" >> $GITHUB_OUTPUT
fi
# remove [bot] from actor name
echo "actor=${GITHUB_ACTOR/\[bot\]/}" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
environment: ${{ inputs.environment || 'production' }}
needs: setup
env:
EXPECTED: ${{ needs.setup.outputs.name }}
strategy:
matrix:
test:
- key: sha
value: ${{ needs.setup.outputs.sha }}
- key: commit
value: ${{ needs.setup.outputs.sha}}
- key: version
value: '1.0.0-${{ github.run_number }}'
- key: branch
value: ${{ needs.setup.outputs.branch }}
- key: ref
value: ${{ github.ref }}
- key: actor
value: ${{ needs.setup.outputs.actor }}
- key: run_number
value: ${{ github.run_number }}
- key: shortcommit
value: ${{ needs.setup.outputs.shortcommit }}
steps:
- name: Check list with ${{ matrix.test.key }}
run: |
RESULT=$(curl -u ${{ secrets.ARTIFACTS_USER }}:${{ secrets.ARTIFACTS_PASSWORD }} \
"${{ vars.ARTIFACTS_URL }}/search/last_success/${{ matrix.test.key }}/github/${{ github.repository }}/${{ github.workflow }}/${{ matrix.test.value }}")
echo $RESULT
if [ "$RESULT" != "$EXPECTED" ]; then
echo "result: $RESULT != $EXPECTED"
exit 1
else
echo SUCCESS!
fi
shell: bash