-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (47 loc) · 1.6 KB
/
develop.yaml
File metadata and controls
54 lines (47 loc) · 1.6 KB
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: Docker develop build
on:
push:
branches: [ "staging", "develop"]
env:
DOCKER_REGISTRY: gcr.io
DOCKER_IMAGE_NAME: trustless-computer-dev/dapp-moderator
jobs:
build-and-push-to-gcr:
runs-on: ubuntu-latest
concurrency:
group: build_develop
cancel-in-progress: false
steps:
- uses: actions/checkout@v3
- name: Get the tag name
id: get_tag_name
run: |
if [[ $GITHUB_REF_NAME == 'staging' || $GITHUB_REF_NAME == 'develop' ]]; then
short_sha=$(echo $GITHUB_SHA | head -c 7)
echo "IMAGE_TAG=${GITHUB_REF_NAME}-${short_sha}" >> $GITHUB_ENV
echo "BUILD_ENV=${GITHUB_REF_NAME}" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "BUILD_ENV=production" >> $GITHUB_ENV
fi
- name: Setup google auth
id: "auth"
uses: "google-github-actions/auth@v0"
with:
credentials_json: ${{ secrets.GCLOUD_DEV_SERVICE_ACCOUNT_JSON }}
- name: Setup docker
uses: docker/setup-buildx-action@v2
- name: Authenticate docker
run: |
gcloud auth configure-docker --quiet gcr.io
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{env.DOCKER_REGISTRY}}/${{env.DOCKER_IMAGE_NAME}}:latest
${{env.DOCKER_REGISTRY}}/${{env.DOCKER_IMAGE_NAME}}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: BUILD_ENV=${{ env.BUILD_ENV }}