docker-dev #159
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: docker-dev | |
| on: | |
| workflow_dispatch: # manually run | |
| inputs: | |
| custom_tag: | |
| description: 'Custom tag to use for the image (defaults to commit hash if empty)' | |
| required: false | |
| images: | |
| description: 'Space-separated list of images to publish (leave empty for all)' | |
| required: false | |
| tag_latest: | |
| description: 'Also publish image with the latest tag' | |
| type: boolean | |
| default: true | |
| required: false | |
| env: | |
| CI: true | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.platform }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - linux/amd64 | |
| - linux/arm64 | |
| runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} | |
| steps: | |
| - name: Prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Docker login | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_LOGIN }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| use: true | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build and push by digest | |
| env: | |
| PLATFORM: ${{ matrix.platform }} | |
| BUILDX_CACHE_FROM: type=gha,scope=build-${{ matrix.platform }} | |
| BUILDX_CACHE_TO: type=gha,scope=build-${{ matrix.platform }},mode=max | |
| run: | | |
| IFS=' ' read -r -a image_array <<< "${{ inputs.images }}" | |
| ./ops/docker-publish-dev.sh "${image_array[@]}" | |
| - name: Upload digests | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| name: Merge manifests | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Docker login | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_LOGIN }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - name: Create manifests and push | |
| run: | | |
| CUSTOM_TAG="${{ inputs.custom_tag }}" | |
| if [ -z "$CUSTOM_TAG" ]; then | |
| CUSTOM_TAG="$(git rev-parse --short HEAD)" | |
| fi | |
| IFS=' ' read -r -a image_array <<< "${{ inputs.images }}" | |
| ./ops/docker-merge-dev.sh "$CUSTOM_TAG" "${{ inputs.tag_latest }}" "${image_array[@]}" |