|
1 | | -name: Build and Publish Docker Image. On dispatch event build the latest tag and push to Docker Hub |
| 1 | +name: Build Docker Image. On tag creation push to Docker Hub. On dispatch event build the latest tag and push to Docker Hub |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
| 5 | + pull_request: |
5 | 6 | push: |
6 | 7 | tags: [ 'v*.*.*' ] |
7 | 8 |
|
|
11 | 12 |
|
12 | 13 | steps: |
13 | 14 | - name: Checkout repository |
14 | | - uses: actions/checkout@v3 |
| 15 | + uses: actions/checkout@v4 |
15 | 16 | with: |
16 | 17 | fetch-depth: 0 |
17 | 18 |
|
|
26 | 27 | run: | |
27 | 28 | git checkout ${{ steps.latest_tag.outputs.LATEST_TAG }} |
28 | 29 |
|
| 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 | +
|
29 | 60 | - name: Set up QEMU |
30 | 61 | uses: docker/setup-qemu-action@v3 |
31 | 62 |
|
|
40 | 71 |
|
41 | 72 | - name: Build and push |
42 | 73 | id: docker_build |
| 74 | + if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }} |
43 | 75 | uses: docker/build-push-action@v6 |
44 | 76 | with: |
45 | 77 | context: . |
46 | 78 | platforms: linux/amd64,linux/arm64 |
47 | 79 | push: true |
48 | 80 | 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