📦 Build and Publish #427
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: 📦 Build and Publish | |
| on: | |
| schedule: | |
| - cron: '30 9 * * *' | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - '*' | |
| workflow_dispatch: | |
| env: | |
| TAG: ${{ github.ref_name == 'main' && 'development' || github.ref_name }} | |
| jobs: | |
| build-and-push-container: | |
| runs-on: ${{ matrix.builder }} | |
| strategy: | |
| matrix: | |
| include: | |
| - builder: ubuntu-24.04 | |
| platform: amd64 | |
| - builder: ubuntu-24.04-arm | |
| platform: arm64 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{github.ref_name}} | |
| - name: Add VERSION file | |
| run: git describe > VERSION | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| # needed for multi-arch builds | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the GitHub container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Log in to the Docker container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ vars.DOCKERHUB_USER }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/${{ matrix.platform }} | |
| provenance: true | |
| push: true | |
| sbom: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-${{ matrix.platform }} | |
| create-multiarch-manifests: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - build-and-push-container | |
| steps: | |
| - name: Login to ghcr.io registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to docker.io registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ vars.DOCKERHUB_USER }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create multiarch manifests | |
| run: | | |
| docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:latest \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64 | |
| docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:${{ env.TAG }} \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64 | |
| docker buildx imagetools create --tag docker.io/${{ github.repository }}:latest \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64 | |
| docker buildx imagetools create --tag docker.io/${{ github.repository }}:${{ env.TAG }} \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \ | |
| ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64 | |
| update-dockerhub-description: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - create-multiarch-manifests | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Update Docker Hub Description | |
| uses: peter-evans/dockerhub-description@v5 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USER }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} |