-
Notifications
You must be signed in to change notification settings - Fork 66
63 lines (63 loc) · 2.58 KB
/
build-and-publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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