Skip to content

Build cf.gov artifact #2440

Build cf.gov artifact

Build cf.gov artifact #2440

Workflow file for this run

name: 'Build cf.gov artifact'
on:
pull_request:
merge_group:
workflow_dispatch:
jobs:
Build:
runs-on: ubuntu-latest
env:
ARTIFACT_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install Act dependencies (if needed)
if: ${{ env.ACT }}
run: corepack enable
- name: Install dependencies
run: yarn
- name: Build frontend
run: yarn run build
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull image to build artifact
run: docker pull ghcr.io/cfpb/cfgov-artifact-builder:latest
- name: Build artifact
run: |
docker run \
-v `pwd`:/cfgov \
ghcr.io/cfpb/cfgov-artifact-builder:latest
- name: Pull image to test artifact
run: docker pull ghcr.io/cfpb/cfgov-artifact-tester:latest
- name: Run built artifact as a Docker container
run: |
docker run \
--name cfgov \
-d \
-v `pwd`:/cfgov:ro \
-p 8000:80 \
--env-file docker/centos7/test.env \
ghcr.io/cfpb/cfgov-artifact-tester:latest
- name: Wait for artifact container to be ready
run: |
timeout 180s bash -c \
'until [ "$(docker inspect -f {{.State.Health.Status}} cfgov)" == "healthy" ]; do sleep 2; done'
# Don't upload artifacts to S3 if PR is against a fork.
- name: Upload artifact to S3
if: "! github.event.pull_request.head.repo.fork"
uses: keithweaver/[email protected]
with:
command: cp
source: cfgov_current_build.zip
destination: s3://${{ secrets.BUCKET }}/cfgov_${{ env.ARTIFACT_SHA }}_build.zip
aws_access_key_id: ${{ secrets.BUILD_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.BUILD_SECRET_ACCESS_KEY }}
aws_region: us-east-1