|
| 1 | +name: publish |
| 2 | + |
| 3 | +on: push |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-and-push-images: |
| 7 | + strategy: |
| 8 | + matrix: |
| 9 | + app: |
| 10 | + - name: backend |
| 11 | + file: backend.Dockerfile |
| 12 | + - name: webapp |
| 13 | + file: webapp.Dockerfile |
| 14 | + - name: maintenance |
| 15 | + file: maintenance.Dockerfile |
| 16 | + runs-on: ubuntu-latest |
| 17 | + env: |
| 18 | + REGISTRY: ghcr.io |
| 19 | + IMAGE_NAME: ${{ github.repository }}/${{ matrix.app.name }} |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + attestations: write |
| 24 | + id-token: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.1.7 |
| 29 | + - name: Log in to the Container registry |
| 30 | + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 |
| 31 | + with: |
| 32 | + registry: ${{ env.REGISTRY }} |
| 33 | + username: ${{ github.actor }} |
| 34 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + - name: Extract metadata (tags, labels) for Docker |
| 36 | + id: meta |
| 37 | + uses: docker/metadata-action@70b2cdc6480c1a8b86edf1777157f8f437de2166 |
| 38 | + with: |
| 39 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 40 | + tags: | |
| 41 | + type=schedule |
| 42 | + type=semver,pattern={{version}} |
| 43 | + type=semver,pattern={{major}}.{{minor}} |
| 44 | + type=semver,pattern={{major}} |
| 45 | + type=ref,event=branch |
| 46 | + type=ref,event=pr |
| 47 | + type=sha |
| 48 | + - name: Build and push Docker images |
| 49 | + id: push |
| 50 | + uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 |
| 51 | + with: |
| 52 | + file: ${{ matrix.app.file }} |
| 53 | + push: true |
| 54 | + build-args: |
| 55 | + APP_IMAGE_TAG_CODE: ${{ github.head_ref || github.ref_name }}-code |
| 56 | + APP_IMAGE_TAG_BASE: ${{ github.head_ref || github.ref_name }}-base |
| 57 | + tags: ${{ steps.meta.outputs.tags }} |
| 58 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments