|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +name: publish image to ghcr.io |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + release: |
| 13 | + types: [published] |
| 14 | + |
| 15 | +env: |
| 16 | + REGISTRY: ghcr.io |
| 17 | + IMAGE_NAME: ${{ github.repository }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + # Push image to GitHub Packages. |
| 21 | + # See also https://docs.docker.com/docker-hub/builds/ |
| 22 | + push: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + packages: write |
| 26 | + contents: read |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout branch |
| 30 | + uses: actions/checkout@v2 |
| 31 | + |
| 32 | + - name: Set up QEMU |
| 33 | + uses: docker/setup-qemu-action@v2 |
| 34 | + |
| 35 | + - name: Login to GitHub Container Registry |
| 36 | + uses: docker/login-action@v2 |
| 37 | + with: |
| 38 | + registry: ${{ env.REGISTRY }} |
| 39 | + username: ${{ github.repository_owner }} |
| 40 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - name: Set up Docker Buildx |
| 43 | + id: buildx |
| 44 | + uses: docker/setup-buildx-action@v2 |
| 45 | + |
| 46 | + - name: Docker meta |
| 47 | + id: meta |
| 48 | + uses: docker/metadata-action@v4 |
| 49 | + with: |
| 50 | + images: | |
| 51 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 52 | + tags: | |
| 53 | + type=raw,value=latest,enable={{is_default_branch}} |
| 54 | + type=semver,pattern={{version}} |
| 55 | +
|
| 56 | + - name: Build and push |
| 57 | + uses: docker/build-push-action@v4 |
| 58 | + with: |
| 59 | + context: . |
| 60 | + file: ./Dockerfile |
| 61 | + cache-from: type=gha |
| 62 | + cache-to: type=gha,mode=max |
| 63 | + platforms: linux/arm64,linux/amd64 |
| 64 | + push: true |
| 65 | + tags: ${{ steps.meta.outputs.tags }} |
| 66 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments