@@ -2,6 +2,7 @@ name: Build and Publish Docker Image. On dispatch event build the latest tag and
22
33on :
44 workflow_dispatch :
5+ pull_request :
56 push :
67 tags : [ 'v*.*.*' ]
78
1112
1213 steps :
1314 - name : Checkout repository
14- uses : actions/checkout@v3
15+ uses : actions/checkout@v4
1516 with :
1617 fetch-depth : 0
1718
2627 run : |
2728 git checkout ${{ steps.latest_tag.outputs.LATEST_TAG }}
2829
30+ - name : Set up Python 3.8
31+ uses : actions/setup-python@v5
32+ with :
33+ python-version : ' 3.8'
34+
35+ - name : Load cached Poetry setup
36+ id : cached_poetry
37+ uses : actions/cache@v4
38+ with :
39+ path : ~/.local
40+ key : poetry-ubuntu-0 # increment to reset cache
41+
42+ - name : Setup Poetry
43+ if : steps.cached_poetry.outputs.cache-hit != 'true'
44+ uses : snok/install-poetry@v1
45+ with :
46+ version : 1.8.3
47+
48+ - name : Add Poetry to PATH
49+ run : echo "$HOME/.local/bin" >> $GITHUB_PATH
50+
51+ - name : Install Poetry Plugin
52+ run : poetry self add "poetry-dynamic-versioning[plugin]"
53+
54+ - name : Get CLI Version
55+ id : cli_version
56+ run : |
57+ echo "::debug::Package version: $(poetry version --short)"
58+ echo "CLI_VERSION=$(poetry version --short)" >> $GITHUB_OUTPUT
59+
2960 - name : Set up QEMU
3061 uses : docker/setup-qemu-action@v3
3162
4071
4172 - name : Build and push
4273 id : docker_build
74+ if : ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }}
4375 uses : docker/build-push-action@v6
4476 with :
4577 context : .
4678 platforms : linux/amd64,linux/arm64
4779 push : true
4880 tags : cycodehq/cycode_cli:${{ steps.latest_tag.outputs.LATEST_TAG }},cycodehq/cycode_cli:latest
81+
82+ - name : Verify build
83+ id : docker_verify_build
84+ if : ${{ github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/v') }}
85+ uses : docker/build-push-action@v6
86+ with :
87+ context : .
88+ platforms : linux/amd64,linux/arm64
89+ push : false
90+ tags : cycodehq/cycode_cli:${{ steps.cli_version.outputs.CLI_VERSION }}
0 commit comments