|
1 | | -# This workflow builds a GitHub release on tag creation. |
| 1 | +# This workflow builds a GitHub release on tag creation and then builds and |
| 2 | +# pushes Docker images to GitHub Container Registry. |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | push: |
|
8 | 9 | name: Create Github Release |
9 | 10 | run-name: "Create Github Release - ${{ github.head_ref || github.ref_name }}" |
10 | 11 |
|
11 | | -permissions: |
12 | | - contents: write |
13 | | - |
14 | 12 | env: |
15 | 13 | COMPOSE_USER: runner |
16 | 14 |
|
17 | 15 | jobs: |
18 | 16 | create-release: |
19 | 17 | runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: write |
20 | 20 | steps: |
21 | 21 | - name: Checkout |
22 | 22 | uses: actions/checkout@v4 |
|
61 | 61 | env: |
62 | 62 | GITHUB_TOKEN: ${{ github.TOKEN }} |
63 | 63 | shell: bash |
| 64 | + |
| 65 | + images: |
| 66 | + needs: create-release |
| 67 | + runs-on: ubuntu-latest |
| 68 | + permissions: |
| 69 | + contents: read |
| 70 | + packages: write |
| 71 | + attestations: write |
| 72 | + id-token: write |
| 73 | + env: |
| 74 | + REGISTRY: ghcr.io |
| 75 | + IMAGE_NAME_MAIN: ${{ github.repository }} |
| 76 | + IMAGE_NAME_NGINX: ${{ github.repository }}-nginx |
| 77 | + steps: |
| 78 | + - name: Checkout repository |
| 79 | + uses: actions/checkout@v5 |
| 80 | + with: |
| 81 | + ref: ${{ github.ref_name }} |
| 82 | + |
| 83 | + - name: Set up QEMU |
| 84 | + uses: docker/setup-qemu-action@v3 |
| 85 | + |
| 86 | + - name: Set up Docker Buildx |
| 87 | + uses: docker/setup-buildx-action@v3 |
| 88 | + |
| 89 | + - name: Log in to the Container registry |
| 90 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 91 | + with: |
| 92 | + registry: ${{ env.REGISTRY }} |
| 93 | + username: ${{ github.actor }} |
| 94 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + |
| 96 | + # Build main |
| 97 | + |
| 98 | + - name: Docker meta (main) |
| 99 | + id: meta-main |
| 100 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 101 | + with: |
| 102 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_MAIN }} |
| 103 | + tags: | |
| 104 | + type=raw,value=${{ github.ref_name }} |
| 105 | +
|
| 106 | + - name: Build and push Docker image |
| 107 | + id: push-main |
| 108 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 109 | + with: |
| 110 | + context: ./infrastructure/display-api-service/ |
| 111 | + file: ./infrastructure/display-api-service/Dockerfile |
| 112 | + build-args: | |
| 113 | + APP_VERSION=${{ github.ref_name }} |
| 114 | + push: true |
| 115 | + tags: ${{ steps.meta-main.outputs.tags }} |
| 116 | + labels: ${{ steps.meta-main.outputs.labels }} |
| 117 | + provenance: mode=max |
| 118 | + sbom: true |
| 119 | + |
| 120 | + - name: Generate artifact attestation |
| 121 | + uses: actions/attest-build-provenance@v3 |
| 122 | + with: |
| 123 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_MAIN}} |
| 124 | + subject-digest: ${{ steps.push-main.outputs.digest }} |
| 125 | + push-to-registry: true |
| 126 | + |
| 127 | + # Build Nginx (depends on main) |
| 128 | + |
| 129 | + - name: Docker meta (nginx) |
| 130 | + id: meta-nginx |
| 131 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 132 | + with: |
| 133 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_NGINX }} |
| 134 | + tags: | |
| 135 | + type=raw,value=${{ github.ref_name }} |
| 136 | +
|
| 137 | + - name: Build and push Docker image |
| 138 | + id: push-nginx |
| 139 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 140 | + with: |
| 141 | + context: ./infrastructure/nginx/ |
| 142 | + file: ./infrastructure/nginx/Dockerfile |
| 143 | + build-args: | |
| 144 | + APP_VERSION=${{ github.ref_name }} |
| 145 | + push: true |
| 146 | + tags: ${{ steps.meta-nginx.outputs.tags }} |
| 147 | + labels: ${{ steps.meta-nginx.outputs.labels }} |
| 148 | + provenance: mode=max |
| 149 | + sbom: true |
| 150 | + |
| 151 | + - name: Generate artifact attestation |
| 152 | + uses: actions/attest-build-provenance@v3 |
| 153 | + with: |
| 154 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_NGINX}} |
| 155 | + subject-digest: ${{ steps.push-nginx.outputs.digest }} |
| 156 | + push-to-registry: true |
0 commit comments