|
1 | 1 | name: Build and push |
2 | 2 |
|
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +env: |
| 7 | + IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/ssh-key-authority |
| 8 | + |
3 | 9 | on: |
4 | 10 | push: |
5 | 11 | branches: [ "master", "dev" ] |
6 | 12 | pull_request: |
7 | 13 | branches: [ "master", "dev" ] |
| 14 | + release: |
| 15 | + types: [ published ] |
8 | 16 |
|
9 | 17 | jobs: |
10 | 18 | build: |
| 19 | + if: github.event_name != 'release' |
11 | 20 | runs-on: ubuntu-latest |
12 | 21 | steps: |
13 | | - - name: Login to Docker Hub |
| 22 | + - &checkout-step |
| 23 | + name: Check out repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - &setup-qemu-step |
| 27 | + name: Set up QEMU |
| 28 | + uses: docker/setup-qemu-action@v3 |
| 29 | + |
| 30 | + - &login-step |
| 31 | + name: Login to Docker Hub |
14 | 32 | uses: docker/login-action@v3 |
15 | 33 | with: |
16 | 34 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
17 | 35 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
18 | 36 |
|
19 | | - - name: Set up Docker Buildx |
| 37 | + - &setup-buildx-step |
| 38 | + name: Set up Docker Buildx |
20 | 39 | uses: docker/setup-buildx-action@v3 |
21 | 40 |
|
22 | 41 | - name: Build and push |
23 | 42 | uses: docker/build-push-action@v6 |
24 | 43 | with: |
| 44 | + context: . |
| 45 | + push: true |
| 46 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 47 | + cache-from: type=gha |
| 48 | + cache-to: type=gha,mode=max |
| 49 | + tags: | |
| 50 | + ${{ env.IMAGE_NAME }}:latest-${{ github.ref_name }} |
| 51 | +
|
| 52 | + release: |
| 53 | + if: github.event_name == 'release' |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - *checkout-step |
| 57 | + |
| 58 | + - *setup-qemu-step |
| 59 | + |
| 60 | + - *login-step |
| 61 | + |
| 62 | + - *setup-buildx-step |
| 63 | + |
| 64 | + - name: Build and push release image |
| 65 | + uses: docker/build-push-action@v6 |
| 66 | + with: |
| 67 | + context: . |
25 | 68 | push: true |
26 | | - tags: ${{ secrets.DOCKERHUB_USERNAME }}/ssh-key-authority:latest-${{ vars.GITHUB_REF_NAME }} |
| 69 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 70 | + tags: | |
| 71 | + ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} |
| 72 | + ${{ env.IMAGE_NAME }}:latest |
0 commit comments