Build, Push, & Deploy #14210
This file contains 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: Build, Push, & Deploy | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: ["Code Checks"] | |
branches: [master] | |
types: [completed] | |
permissions: | |
contents: read | |
jobs: | |
build_and_push: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
name: Build and Push | |
env: | |
BUNDLE_ENTERPRISE__CONTRIBSYS__COM: ${{ secrets.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Environment | |
run: echo "VETS_API_USER_ID=$(id -u)" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4.0.2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-gov-west-1 | |
- name: Login to ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build Docker Image | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_SUMMARY: false | |
with: | |
build-args: | | |
BUNDLE_ENTERPRISE__CONTRIBSYS__COM=${{ env.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }} | |
USER_ID=${{ env.VETS_API_USER_ID }} | |
RAILS_ENV=production | |
context: . | |
push: true | |
tags: | | |
${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPOSITORY }}:${{ github.sha }} | |
cache-from: type=registry,ref=$ECR_REGISTRY/$ECR_REPOSITORY | |
cache-to: type=inline | |
deploy: | |
needs: build_and_push | |
if: github.ref == 'refs/heads/master' && ${{ github.event.workflow_run.conclusion == 'success' }} | |
uses: department-of-veterans-affairs/vets-api/.github/workflows/deploy-template.yml@master | |
with: | |
ecr_repository: "vets-api" | |
manifests_directory: "vets-api" | |
auto_deploy_envs: "dev staging prod sandbox" | |
commit_sha: ${{ github.sha }} | |
secrets: | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |