-
Notifications
You must be signed in to change notification settings - Fork 5
54 lines (51 loc) · 1.84 KB
/
pull_request.yml
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
name: PR
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: "1.21.x"
- name: Checkout code
uses: actions/checkout@v3
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: go get
- name: Build
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo
docker-push:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Tag
run: |
CLEAN_TAG=$(echo "${{ github.event.pull_request.head.ref }}" | tr / -)
echo "TAG=$CLEAN_TAG" >> $GITHUB_ENV
- name: Build
run: >
docker build -t onsdigital/eq-questionnaire-launcher:$TAG
-t ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-launcher:$TAG .
- name: Push to Docker Hub
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
echo "Pushing with tag [$TAG]"
docker push onsdigital/eq-questionnaire-launcher:$TAG
- name: Push to GAR
env:
GAR_SERVICE_KEY: ${{ secrets.GAR_SERVICE_KEY }}
run: |
echo $GAR_SERVICE_KEY | docker login -u _json_key --password-stdin https://${{ secrets.GAR_LOCATION }}
gcloud auth configure-docker ${{ secrets.GAR_LOCATION }}
echo "Pushing to GAR with tag $TAG"
docker push ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-launcher:$TAG