|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + tag_release: |
| 13 | + if: ${{ github.event_name == 'push' }} |
| 14 | + runs-on: ubuntu-20.04 |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + outputs: |
| 18 | + version: ${{steps.tagging.outputs.new_tag}} |
| 19 | + steps: |
| 20 | + |
| 21 | + - name: Bump version and push tag |
| 22 | + id: tagging |
| 23 | + uses: anothrNick/[email protected] |
| 24 | + env: |
| 25 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + DEFAULT_BUMP: patch |
| 27 | + |
| 28 | + publish_docker_image: |
| 29 | + needs: [tag_release] |
| 30 | + runs-on: ubuntu-20.04 |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + packages: write |
| 34 | + # This is used to complete the identity challenge |
| 35 | + # with sigstore/fulcio when running outside of PRs. |
| 36 | + id-token: write |
| 37 | + |
| 38 | + env: |
| 39 | + REGISTRY: ghcr.io |
| 40 | + # github.repository as <account>/<repo> |
| 41 | + IMAGE_NAME: ${{ github.repository }} |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout repository |
| 45 | + |
| 46 | + |
| 47 | + # Set up QEMU for cross-platform builds |
| 48 | + - name: Set up QEMU |
| 49 | + |
| 50 | + |
| 51 | + # Set up BuildKit Docker container builder to be able to build |
| 52 | + # multi-platform images and export cache |
| 53 | + - name: Set up Docker Buildx |
| 54 | + |
| 55 | + |
| 56 | + - name: Log into registry ${{ env.REGISTRY }} |
| 57 | + |
| 58 | + with: |
| 59 | + registry: ${{ env.REGISTRY }} |
| 60 | + username: ${{ github.actor }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + |
| 63 | + - name: Build and push Docker image with Buildx |
| 64 | + id: build-and-push |
| 65 | + |
| 66 | + with: |
| 67 | + context: . |
| 68 | + tags: | |
| 69 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.tag_release.outputs.version }} |
| 70 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
| 71 | + push: true |
| 72 | + platforms: linux/amd64,linux/arm64 |
0 commit comments