Skip to content

Build And Publish Preview Environment #6379

Build And Publish Preview Environment

Build And Publish Preview Environment #6379

name: Build And Publish Preview Environment
run-name: Build And Publish Preview Environment
on: [push]
jobs:
build-and-publish:
runs-on: ubuntu-latest
env:
BUNDLE_ENTERPRISE__CONTRIBSYS__COM: ${{ secrets.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }}
steps:
- name: Check out code
uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
fetch-depth: 0 # needed to get enough tag history to determine the semver
- name: Setup Environment
run: echo "VETS_API_USER_ID=$(id -u)" >> $GITHUB_ENV
- name: Git Version
id: version
uses: codacy/[email protected]
with:
release-branch: master
- name: Echo the version
run: |
echo ${{ steps.version.outputs.version }}
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
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 Amazon ECR
id: ecr-login
uses: aws-actions/[email protected]
with:
mask-password: true
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
build-args: |
BUNDLE_ENTERPRISE__CONTRIBSYS__COM=${{ env.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }}
USER_ID=${{ env.VETS_API_USER_ID }}
RAILS_ENV=production
context: .
file: Dockerfile-k8s
push: true
tags: |
${{ steps.ecr-login.outputs.registry }}/dsva/preview-environment/vets-api:${{ steps.version.outputs.version }}
- name: Create git tag if on master
if: github.ref == 'refs/heads/master'
run: |
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}
- name: Inject Version into helm chart
working-directory: ./helmCharts/vets-api
run: |
yq e -i '.image.tag = "${{ steps.version.outputs.version }}"' values.yaml
yq e -i '.version = "${{ steps.version.outputs.version }}"' Chart.yaml
- name: helm Package and Publish
working-directory: ./helmCharts
run: |
helm package vets-api
aws ecr get-login-password --region us-gov-west-1 | helm registry login --username AWS --password-stdin 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com
helm push vets-api-${{ steps.version.outputs.version }}.tgz oci://008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/dsva/helm