-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (57 loc) · 1.97 KB
/
app.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
name: Application CI/CD
on:
push:
branches:
- 'main'
jobs:
push_to_registry:
name: Push Image to GCP
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip')"
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
version: 418
- name: Auth to GCloud Docker
shell: bash
run: |
gcloud auth configure-docker us-east4-docker.pkg.dev
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-${{ github.sha }}
restore-keys: |
buildx-
- name: Generate build tag
env:
SHA: ${{ github.sha }}
run: |
echo "BUILD_TAG=${GITHUB_SHA:0:7}-$(date +%Y%m%d-%H%M%S)" >> $GITHUB_ENV
- name: Build Image
id: build-image
uses: docker/build-push-action@v3
with:
context: .
tags: |
"${{ vars.REGISTRY_HOSTNAME }}development/${{ vars.IMAGE }}:${{ env.BUILD_TAG }}"
"${{ vars.REGISTRY_HOSTNAME }}development/${{ vars.IMAGE }}:latest"
"${{ vars.REGISTRY_HOSTNAME }}prod/${{ vars.IMAGE }}:${{ env.BUILD_TAG }}"
"${{ vars.REGISTRY_HOSTNAME }}prod/${{ vars.IMAGE }}:latest"
build-args: |
VERSION=${{ env.BUILD_TAG }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache