smoke pack DRY, workflow extraction, CI unblock #51
Workflow file for this run
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
| # Build and publish BOPS container images to ghcr.io | |
| # | |
| # Builds two images in parallel: | |
| # - ghcr.io/co-cddo/ndx_try_aws_scenarios-bops:latest (back-office + worker) | |
| # - ghcr.io/co-cddo/ndx_try_aws_scenarios-bops-applicants:latest (public portal) | |
| # | |
| # Both clone their upstream repos at pinned commits, apply our overlay files, | |
| # and build using the upstream Dockerfile.production. | |
| name: Build BOPS Container Images | |
| on: | |
| push: | |
| branches: [main, feat/bops-planning] | |
| paths: | |
| - 'cloudformation/scenarios/bops-planning/docker/**' | |
| - '.github/workflows/docker-build-bops.yml' | |
| pull_request: | |
| paths: | |
| - 'cloudformation/scenarios/bops-planning/docker/**' | |
| - '.github/workflows/docker-build-bops.yml' | |
| workflow_dispatch: | |
| inputs: | |
| push_image: | |
| description: 'Push images to registry' | |
| required: false | |
| default: true | |
| type: boolean | |
| env: | |
| REGISTRY: ghcr.io | |
| # Pin to specific commits for reproducibility — update these when upgrading BOPS | |
| BOPS_REPO: unboxed/bops | |
| BOPS_COMMIT: main | |
| BOPS_APPLICANTS_REPO: unboxed/bops-applicants | |
| BOPS_APPLICANTS_COMMIT: main | |
| jobs: | |
| changes: | |
| name: Check for Docker changes | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| outputs: | |
| docker: ${{ steps.filter.outputs.docker }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| docker: | |
| - 'cloudformation/scenarios/bops-planning/docker/**' | |
| - '.github/workflows/docker-build-bops.yml' | |
| build-bops: | |
| name: Build BOPS Back-Office | |
| runs-on: ubuntu-latest | |
| needs: [changes] | |
| if: | | |
| always() && | |
| (needs.changes.result == 'skipped' || needs.changes.outputs.docker == 'true') | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Clone BOPS source | |
| run: | | |
| git clone --depth 1 https://github.com/${{ env.BOPS_REPO }}.git bops-src | |
| if [ "${{ env.BOPS_COMMIT }}" != "main" ]; then | |
| cd bops-src | |
| git fetch --depth 1 origin ${{ env.BOPS_COMMIT }} | |
| git checkout ${{ env.BOPS_COMMIT }} | |
| cd .. | |
| fi | |
| - name: Copy overlay files | |
| run: | | |
| mkdir -p bops-src/scripts | |
| cp cloudformation/scenarios/bops-planning/docker/bops/config/initializers/default_local_authority.rb bops-src/config/initializers/ | |
| cp cloudformation/scenarios/bops-planning/docker/bops/scripts/seed_sample_data.rb bops-src/scripts/ | |
| cp cloudformation/scenarios/bops-planning/docker/bops/scripts/seed-entrypoint.sh bops-src/scripts/ | |
| cp cloudformation/scenarios/bops-planning/docker/bops/scripts/init-bops.sh bops-src/scripts/ | |
| cp cloudformation/scenarios/bops-planning/docker/bops/entrypoint.sh bops-src/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/co-cddo/ndx_try_aws_scenarios-bops | |
| tags: | | |
| type=sha,prefix=sha- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }} | |
| - name: Build and push BOPS image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: bops-src | |
| file: bops-src/Dockerfile.production | |
| push: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/bops-planning' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image != 'false')) }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=bops | |
| cache-to: type=gha,mode=max,scope=bops | |
| platforms: linux/amd64 | |
| - name: Output image details | |
| run: | | |
| echo "## BOPS Image Built" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| build-bops-applicants: | |
| name: Build BOPS Applicants Portal | |
| runs-on: ubuntu-latest | |
| needs: [changes] | |
| if: | | |
| always() && | |
| (needs.changes.result == 'skipped' || needs.changes.outputs.docker == 'true') | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Clone BOPS-Applicants source | |
| run: | | |
| git clone --depth 1 https://github.com/${{ env.BOPS_APPLICANTS_REPO }}.git bops-applicants-src | |
| if [ "${{ env.BOPS_APPLICANTS_COMMIT }}" != "main" ]; then | |
| cd bops-applicants-src | |
| git fetch --depth 1 origin ${{ env.BOPS_APPLICANTS_COMMIT }} | |
| git checkout ${{ env.BOPS_APPLICANTS_COMMIT }} | |
| cd .. | |
| fi | |
| - name: Copy overlay files | |
| run: | | |
| cp cloudformation/scenarios/bops-planning/docker/bops-applicants/config/initializers/default_local_authority.rb bops-applicants-src/config/initializers/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/co-cddo/ndx_try_aws_scenarios-bops-applicants | |
| tags: | | |
| type=sha,prefix=sha- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }} | |
| - name: Build and push BOPS-Applicants image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: bops-applicants-src | |
| file: bops-applicants-src/Dockerfile.production | |
| push: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/bops-planning' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image != 'false')) }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=bops-applicants | |
| cache-to: type=gha,mode=max,scope=bops-applicants | |
| platforms: linux/amd64 | |
| - name: Output image details | |
| run: | | |
| echo "## BOPS-Applicants Image Built" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY |