diff --git a/.github/workflows/build-multiarch.yaml b/.github/workflows/build-multiarch.yaml index b9210b2..88b4fb8 100644 --- a/.github/workflows/build-multiarch.yaml +++ b/.github/workflows/build-multiarch.yaml @@ -16,29 +16,29 @@ on: push: branches: - main - - dj-maisy/test_shared_matrix schedule: - - cron: '0 3 * * *' + - cron: '34 3 * * *' jobs: configure_builds: - name: Configure Build Settings (from config.json) - runs-on: ubuntu-22.04 + name: Read configuration from build-matrix.json + runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - name: Set Matrix Data - id: set-matrix - run: echo "matrix=$(jq -c . < .github/config.json)" >> $GITHUB_OUTPUT + - uses: actions/checkout@v4 + with: + show-progress: false + - id: set-matrix + run: echo "matrix=$(jq -c . < build-matrix.json)" >> $GITHUB_OUTPUT + # TODO: can we push the target arch into the build matrix to avoid duplicating these jobs? build_and_push_amd64: name: Build ruby_${{ join(matrix.version.rubyver, '.') }} for AMD64 and push to GHCR - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest needs: configure_builds strategy: - matrix: ${{ fromJson(needs.configure_builds.outputs.matrix)}} + matrix: ${{ fromJson(needs.configure_builds.outputs.matrix) }} permissions: packages: write steps: @@ -49,21 +49,18 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout from GitHub - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: ref: ${{ inputs.gitRef || github.ref }} - - - name: Set up Docker BuildX - id: buildx - uses: docker/setup-buildx-action@v3 + show-progress: false + + - uses: docker/setup-buildx-action@v3 - - name: Calculate Image Tags - id: calculate-image-tags + - id: calculate-image-tags run: | CREATED_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" echo "createdDate=${CREATED_DATE}" >> $GITHUB_OUTPUT - + - name: Generate Base Image Metadata uses: docker/metadata-action@v5 id: base-image-metadata @@ -108,8 +105,7 @@ jobs: type=sha,enable=true,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64,format=short type=sha,enable=true,priority=100,format=long,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64 - - name: Build Base Image - id: build-base-image + - id: build-base-image uses: docker/build-push-action@v5 with: file: base.Dockerfile @@ -124,8 +120,7 @@ jobs: tags: ${{ steps.base-image-metadata.outputs.tags }} labels: ${{ steps.base-image-metadata.outputs.labels }} - - name: Build Builder Image - id: build-builder-image + - id: build-builder-image uses: docker/build-push-action@v5 with: file: builder.Dockerfile @@ -143,10 +138,10 @@ jobs: build_and_push_arm64: name: Build ruby_${{ join(matrix.version.rubyver, '.') }} for ARM64 and push to GHCR - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest needs: configure_builds strategy: - matrix: ${{ fromJson(needs.configure_builds.outputs.matrix)}} + matrix: ${{ fromJson(needs.configure_builds.outputs.matrix) }} permissions: packages: write steps: @@ -157,26 +152,23 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout from GitHub - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: ref: ${{ inputs.gitRef || github.ref }} + show-progress: false - - name: Set up QEMU (on ARM64 Only) + - name: Set up QEMU for ARM64 build uses: docker/setup-qemu-action@v3 with: platforms: arm64 - - - name: Set up Docker BuildX - id: buildx - uses: docker/setup-buildx-action@v3 - - name: Calculate Image Tags - id: calculate-image-tags + - uses: docker/setup-buildx-action@v3 + + - id: calculate-image-tags run: | CREATED_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" echo "createdDate=${CREATED_DATE}" >> $GITHUB_OUTPUT - + - name: Generate Base Image Metadata uses: docker/metadata-action@v5 id: base-image-metadata @@ -221,8 +213,7 @@ jobs: type=sha,enable=true,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-arm64,format=short type=sha,enable=true,priority=100,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-arm64,format=long - - name: Build Base Image - id: build-base-image + - id: build-base-image uses: docker/build-push-action@v5 with: file: base.Dockerfile @@ -237,8 +228,7 @@ jobs: tags: ${{ steps.base-image-metadata.outputs.tags }} labels: ${{ steps.base-image-metadata.outputs.labels }} - - name: Build Builder Image - id: build-builder-image + - id: build-builder-image uses: docker/build-push-action@v5 with: file: builder.Dockerfile @@ -261,9 +251,9 @@ jobs: - configure_builds - build_and_push_amd64 - build_and_push_arm64 - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: - matrix: ${{ fromJson(needs.configure_builds.outputs.matrix)}} + matrix: ${{ fromJson(needs.configure_builds.outputs.matrix) }} permissions: packages: write steps: @@ -274,11 +264,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout from GitHub - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: ref: ${{ inputs.gitRef || github.ref }} - + show-progress: false + - name: Create SHA manifest and push for Ruby Base Images run: | docker manifest create \ @@ -302,7 +292,7 @@ jobs: --amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-amd64 \ --amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-arm64 docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }} - + - name: Create Ruby Versioned manifest and push for Ruby Builder Images run: | docker manifest create \ diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 90345b0..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build and push images - -on: - workflow_dispatch: - inputs: - gitRef: - description: Commit, tag or branch name to deploy - required: true - type: string - default: main - noPushToRegistry: - description: Build only, skip pushing to registry - required: true - type: boolean - default: false - -jobs: - build_and_push: - name: Build ruby_${{ matrix.version }} images and push to GHCR - runs-on: ubuntu-22.04 - strategy: - matrix: - version: ['3_1', '3_2', '3_3'] - permissions: - packages: write - steps: - - name: Login to GHCR - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.gitRef }} - show-progress: false - - name: Build images (without pushing to registry) - if: ${{ inputs.noPushToRegistry }} - env: - DRY_RUN: "1" - run: ./build.sh ${{ matrix.version }} - - name: Build and push images - if: ${{ !inputs.noPushToRegistry }} - run: ./build.sh ${{ matrix.version }} \ No newline at end of file diff --git a/.github/config.json b/build-matrix.json similarity index 100% rename from .github/config.json rename to build-matrix.json