-
Notifications
You must be signed in to change notification settings - Fork 66
82 lines (79 loc) · 3.22 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Build And Publish Preview Environment
run-name: Build And Publish Preview Environment
on: [push]
permissions: write-all
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/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0 # max depth
- 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-region: us-gov-west-1
role-to-assume: arn:aws-us-gov:iam::008577686731:role/prt-gha-oidc-role
- 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@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: .
file: Dockerfile
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
- name: Add Failure label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ github.event_name == 'pull_request' && failure() && !contains(github.event.pull_request.labels.*.name, 'pe-failure') }}
with:
number: ${{ github.event.pull_request.number }}
labels: |
pe-failure
- name: Remove Failure label
uses: actions-ecosystem/action-remove-labels@v1
if: ${{ github.event_name == 'pull_request' && success() && contains(github.event.pull_request.labels.*.name, 'pe-failure') }}
with:
number: ${{ github.event.pull_request.number }}
labels: |
pe-failure