|
| 1 | +name: Docker |
| 2 | + |
| 3 | +# This workflow uses actions that are not certified by GitHub. |
| 4 | +# They are provided by a third-party and are governed by |
| 5 | +# separate terms of service, privacy policy, and support |
| 6 | +# documentation. |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [ v3.16 ] |
| 11 | + # Publish semver tags as releases. |
| 12 | + tags: [ 'v*.*.*' ] |
| 13 | + |
| 14 | +env: |
| 15 | + # Use docker.io for Docker Hub if empty |
| 16 | + REGISTRY: ghcr.io |
| 17 | + # github.repository as <account>/<repo> |
| 18 | + IMAGE_NAME: ${{ github.repository }} |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + packages: write |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v3 |
| 31 | + |
| 32 | + - name: Set up QEMU |
| 33 | + uses: docker/setup-qemu-action@v2 |
| 34 | + |
| 35 | + - name: Set up Docker Buildx |
| 36 | + uses: docker/setup-buildx-action@v2 |
| 37 | + |
| 38 | + # Login against a Docker registry except on PR |
| 39 | + # https://github.com/docker/login-action |
| 40 | + - name: Log into registry ${{ env.REGISTRY }} |
| 41 | + if: github.event_name != 'pull_request' |
| 42 | + uses: docker/login-action@v1 |
| 43 | + with: |
| 44 | + registry: ${{ env.REGISTRY }} |
| 45 | + username: ${{ github.actor }} |
| 46 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + # Extract metadata (tags, labels) for Docker |
| 49 | + # https://github.com/docker/metadata-action |
| 50 | + - name: Extract Docker metadata |
| 51 | + id: meta |
| 52 | + uses: docker/metadata-action@v4 |
| 53 | + with: |
| 54 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 55 | + |
| 56 | + # Build and push Docker image with Buildx (don't push on PR) |
| 57 | + # https://github.com/docker/build-push-action |
| 58 | + - name: Build and push Docker image |
| 59 | + uses: docker/build-push-action@v3 |
| 60 | + with: |
| 61 | + context: . |
| 62 | + platforms: linux/amd64, linux/arm/v7, linux/arm64 |
| 63 | + push: ${{ github.event_name != 'pull_request' }} |
| 64 | + tags: ${{ steps.meta.outputs.tags }} |
| 65 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments