|
| 1 | +name: Build and Publish Docker Image. On dispatch event build the latest tag and push to Docker Hub |
| 2 | + |
1 | 3 | on: |
2 | 4 | workflow_dispatch: |
3 | | - |
4 | | -permissions: |
5 | | - # Write permission needed for creating a tag. |
6 | | - contents: write |
| 5 | + push: |
| 6 | + tags: [ 'v*.*.*' ] |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - main: |
| 9 | + docker: |
10 | 10 | runs-on: ubuntu-latest |
| 11 | + |
11 | 12 | steps: |
12 | | - - |
13 | | - name: Checkout |
14 | | - uses: actions/checkout@v2 |
15 | | - - |
16 | | - name: Set up QEMU |
17 | | - uses: docker/setup-qemu-action@v1 |
18 | | - - |
19 | | - name: Set up Docker Buildx |
20 | | - uses: docker/setup-buildx-action@v1 |
21 | | - - |
22 | | - name: Login to DockerHub Registry |
23 | | - env: |
24 | | - DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
25 | | - DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} |
26 | | - run: echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USER" --password-stdin |
27 | | - |
28 | | - - name: Bump version |
29 | | - id: bump_version |
30 | | - uses: anothrNick/[email protected] |
31 | | - env: |
32 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
33 | | - DEFAULT_BUMP: minor |
34 | | - |
35 | | - - |
36 | | - name: Build and push |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v3 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Get latest release tag |
| 19 | + id: latest_tag |
| 20 | + run: | |
| 21 | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 22 | + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT |
| 23 | +
|
| 24 | + - name: Check out latest release tag |
| 25 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 26 | + run: | |
| 27 | + git checkout ${{ steps.latest_tag.outputs.LATEST_TAG }} |
| 28 | +
|
| 29 | + - name: Set up QEMU |
| 30 | + uses: docker/setup-qemu-action@v3 |
| 31 | + |
| 32 | + - name: Set up Docker Buildx |
| 33 | + uses: docker/setup-buildx-action@v3 |
| 34 | + |
| 35 | + - name: Login to Docker Hub |
| 36 | + uses: docker/login-action@v3 |
| 37 | + with: |
| 38 | + username: ${{ secrets.DOCKERHUB_USER }} |
| 39 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 40 | + |
| 41 | + - name: Build and push |
37 | 42 | id: docker_build |
38 | | - uses: docker/build-push-action@v3 |
| 43 | + uses: docker/build-push-action@v6 |
39 | 44 | with: |
40 | 45 | context: . |
41 | | - file: ./Dockerfile |
| 46 | + platforms: linux/amd64,linux/arm64 |
42 | 47 | push: true |
43 | | - tags: cycodehq/cycode_cli:${{ steps.bump_version.outputs.new_tag }} |
44 | | - - |
45 | | - name: Image digest |
46 | | - run: echo ${{ steps.docker_build.outputs.digest }} |
| 48 | + tags: cycodehq/cycode_cli:${{ steps.latest_tag.outputs.LATEST_TAG }},cycodehq/cycode_cli:latest |
0 commit comments