|
| 1 | +name: Create and publish Container image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + |
| 13 | +env: |
| 14 | + REGISTRY: ghcr.io |
| 15 | + IMAGE_NAME: ${{ github.repository }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-push-image: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + continue-on-error: true |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + packages: write |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + include: |
| 27 | + - container: Containerfile.debian |
| 28 | + autotag: false |
| 29 | + suffix: -debian |
| 30 | + - container: Containerfile.alpine |
| 31 | + autotag: ${{ github.ref == 'refs/heads/master' && 'true' || 'auto' }} |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v3 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: Set up QEMU |
| 40 | + uses: docker/setup-qemu-action@v2 |
| 41 | + |
| 42 | + - name: Set up Docker Buildx |
| 43 | + uses: docker/setup-buildx-action@v2 |
| 44 | + |
| 45 | + - name: Login to Container registry |
| 46 | + uses: docker/login-action@v2 |
| 47 | + with: |
| 48 | + registry: ${{ env.REGISTRY }} |
| 49 | + username: ${{ github.actor }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + - name: Docker meta |
| 53 | + id: meta |
| 54 | + uses: docker/metadata-action@v4 |
| 55 | + with: |
| 56 | + images: | |
| 57 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 58 | + tags: | |
| 59 | + type=ref,event=branch |
| 60 | + type=ref,event=pr |
| 61 | + type=edge |
| 62 | + type=semver,pattern={{version}} |
| 63 | + type=semver,pattern={{major}}.{{minor}} |
| 64 | + type=semver,pattern={{major}} |
| 65 | + flavor: | |
| 66 | + latest=${{ matrix.autotag }} |
| 67 | + suffix=${{ matrix.suffix }} |
| 68 | +
|
| 69 | + - name: Build and push |
| 70 | + uses: docker/build-push-action@v4 |
| 71 | + with: |
| 72 | + platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 |
| 73 | + context: . |
| 74 | + file: ${{ matrix.container }} |
| 75 | + push: ${{ github.event_name != 'pull_request' }} |
| 76 | + tags: ${{ steps.meta.outputs.tags }} |
| 77 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments