@@ -2,37 +2,73 @@ name: CI/CD
2
2
3
3
on :
4
4
push :
5
+ workflow_dispatch :
5
6
6
- jobs :
7
+ concurrency :
8
+ group : ${{ github.ref }}
9
+ cancel-in-progress : true
7
10
8
- test_return :
11
+ jobs :
12
+ version :
9
13
runs-on : ubuntu-latest
14
+ outputs :
15
+ semver : ${{ steps.parse.outputs.semver }}
16
+ major : ${{ steps.parse.outputs.major }}
17
+ minor : ${{ steps.parse.outputs.minor }}
18
+ patch : ${{ steps.parse.outputs.patch }}
19
+ exists : ${{ steps.parse.outputs.exists }}
10
20
steps :
11
21
- uses : actions/checkout@v3
12
- - name : ' Integration test: return'
13
- id : output-set
14
- uses : ./
15
- with :
16
- script : |
17
- "return"
18
- - run : |
19
- expected="return"
20
- output="${{steps.output-set.outputs.result}}"
21
- [[ "$output" != "$expected" ]] && echo "::error::❌ Expected '$expected', got '$output'" && exit 1
22
- echo "✅ Test passed, outputs.result: ${{toJSON(steps.output-set.outputs.result)}}"
22
+ - uses : pkgxdev/dev@v0
23
+ - name : Parse & check version
24
+ id : parse
25
+ run : |
26
+ parse_version_component() {
27
+ component=$(echo "$1" | cut -f"$2" -d.)
28
+ if [ -z "$component" ]; then
29
+ echo "Could not parse version format: $1"
30
+ exit 1
31
+ fi
32
+ echo "$component"
33
+ }
34
+ check_git_tag_exists() {
35
+ git fetch --prune --unshallow --tags
36
+ git show-ref --tags v$1 --quiet && echo "true" || echo "false"
37
+ }
38
+ echo "semver=$VERSION" >> $GITHUB_OUTPUT
39
+ echo "major=$(parse_version_component "$VERSION" 1)" >> $GITHUB_OUTPUT
40
+ echo "minor=$(parse_version_component "$VERSION" 2)" >> $GITHUB_OUTPUT
41
+ echo "patch=$(parse_version_component "$VERSION" 3)" >> $GITHUB_OUTPUT
42
+ echo "exists=$(check_git_tag_exists "$VERSION")" >> $GITHUB_OUTPUT
43
+ echo GitHub Output: $(cat $GITHUB_OUTPUT)
23
44
24
- test_context :
45
+ build :
25
46
runs-on : ubuntu-latest
26
47
steps :
27
48
- uses : actions/checkout@v3
28
- - name : ' Integration test: context'
29
- id : output-set
30
- uses : ./
49
+ - uses : docker/setup-buildx-action@v3
50
+ - uses : docker/metadata-action@v5
51
+ id : meta
52
+ with :
53
+ images : elixir_script:test
54
+ - uses : actions/cache@v3
55
+ with :
56
+ path : /tmp/.buildx-cache
57
+ key : ${{ runner.os }}-buildx
58
+ restore-keys : |
59
+ ${{ runner.os }}-buildx-
60
+ - name : Build image
61
+ uses : docker/build-push-action@v5
62
+ with :
63
+ context : .
64
+ file : .github/Dockerfile
65
+ tags : elixir_script:test
66
+ outputs : type=docker,dest=/tmp/elixir_script.tar
67
+ cache-from : type=local,src=/tmp/.buildx-cache
68
+ cache-to : type=local,dest=/tmp/.buildx-cache
69
+ labels : ${{ steps.meta.outputs.labels }}
70
+ - name : Upload image as artifact
71
+ uses : actions/upload-artifact@v3
31
72
with :
32
- script : |
33
- Map.keys(context)
34
- - run : |
35
- expected="[__struct__,action,actor,api_url,event_name,graphql_url,job,payload,ref,run_id,run_number,server_url,sha,workflow]"
36
- output="${{steps.output-set.outputs.result}}"
37
- [[ "$output" != "$expected" ]] && echo "::error::❌ Expected '$expected', got '$output'" && exit 1
38
- echo "✅ Test passed, outputs.result: ${{toJSON(steps.output-set.outputs.result)}}"
73
+ name : elixir_script
74
+ path : /tmp/elixir_script.tar
0 commit comments