Docker Compiler Base #11
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 Compiler Base | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| skip_base: | |
| description: 'Skip base image build' | |
| type: boolean | |
| default: false | |
| trigger_template: | |
| description: 'Trigger template workflow after base build' | |
| type: boolean | |
| default: true | |
| schedule: | |
| # Base image: once daily at 23:00 UTC (1 hour before smart build at 00:00) | |
| - cron: '0 23 * * *' | |
| env: | |
| BASE_IMAGE: niteris/fastled-compiler-base | |
| jobs: | |
| credentials: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| docker_username: ${{ steps.credentials.outputs.docker_username }} | |
| docker_password: ${{ steps.credentials.outputs.docker_password }} | |
| registry_base: ${{ steps.credentials.outputs.registry_base }} | |
| steps: | |
| - name: Output encoded credentials | |
| id: credentials | |
| env: | |
| docker_username: niteris | |
| docker_password: ${{ secrets.DOCKER_PASSWORD }} | |
| registry_base: ${{ env.BASE_IMAGE }} | |
| run: | | |
| echo "docker_username=$(echo -n "niteris" | base64 -w0 | base64 -w0)" >> $GITHUB_OUTPUT | |
| echo "docker_password=$(echo $docker_password | base64 -w0 | base64 -w0)" >> $GITHUB_OUTPUT | |
| echo "registry_base=$(echo $registry_base | base64 -w0 | base64 -w0)" >> $GITHUB_OUTPUT | |
| # ============================================================================ | |
| # BASE IMAGE BUILD | |
| # ============================================================================ | |
| build-base: | |
| if: github.event.inputs.skip_base != 'true' | |
| needs: credentials | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - runs_on: ubuntu-24.04 | |
| platform: linux/amd64 | |
| - runs_on: ubuntu-24.04-arm | |
| platform: linux/arm64 | |
| uses: ./.github/workflows/docker_build_compiler.yml | |
| with: | |
| runs_on: ${{ matrix.arch.runs_on }} | |
| platform: ${{ matrix.arch.platform }} | |
| dockerfile: Dockerfile.base | |
| tag: latest | |
| group: base | |
| platforms: linux/amd64,linux/arm64 | |
| secrets: | |
| env_vars: | | |
| docker_username=${{ needs.credentials.outputs.docker_username }} | |
| docker_password=${{ needs.credentials.outputs.docker_password }} | |
| docker_registry_image=${{ needs.credentials.outputs.registry_base }} | |
| merge-base: | |
| if: github.event.inputs.skip_base != 'true' | |
| runs-on: ubuntu-24.04 | |
| needs: build-base | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-base-* | |
| merge-multiple: true | |
| - name: Verify digests were downloaded | |
| run: | | |
| if [ ! -d /tmp/digests ] || [ -z "$(ls -A /tmp/digests)" ]; then | |
| echo "ERROR: No digests found! Build jobs likely failed." | |
| exit 1 | |
| fi | |
| echo "Found digests:" | |
| ls -la /tmp/digests/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BASE_IMAGE }} | |
| tags: type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: niteris | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.BASE_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.BASE_IMAGE }}:latest | |
| trigger-smart-build: | |
| if: github.event.inputs.trigger_template != 'false' | |
| runs-on: ubuntu-latest | |
| needs: merge-base | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Trigger smart build workflow | |
| run: | | |
| # Trigger the daily smart build workflow after base image is ready | |
| gh workflow run docker_compiler_smart_build.yml | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |