-
Notifications
You must be signed in to change notification settings - Fork 3
112 lines (100 loc) · 4.87 KB
/
docker.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: build-docker-image
on:
pull_request:
branches:
- c4t
- dev
- suite
- suite-tagging
push:
branches:
- c4t
- dev
- suite
- suite-tagging
tags:
- v*
env:
node_version: 16
module_docker_image: "europe-west3-docker.pkg.dev/pwk-c4t-dev/camino-suite-apps/camino-suite-host"
jobs:
build_docker:
name: Build Docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Prepare Image Tag
id: setDefaults
run: |
DOCKER_IMAGE_NAME="europe-west3-docker.pkg.dev/pwk-c4t-dev/internal-camino-dev/camino-suite"
echo "create_tag=false" >> $GITHUB_OUTPUT
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:stage" >> $GITHUB_OUTPUT
echo "build_env=stage" >> $GITHUB_OUTPUT
echo "branch=suite-tagging" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/c4t" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:stage" >> $GITHUB_OUTPUT
echo "build_env=stage" >> $GITHUB_OUTPUT
echo "branch=c4t" >> $GITHUB_OUTPUT
CURRENT_TAG=$(git describe --abbrev=0 --tags)
if [[ $CURRENT_TAG == *"-rc"* ]]; then
TAG_TEMP=$(echo "$CURRENT_TAG"|awk -F'-rc' -v OFS='-rc' '{$2=sprintf("%1d",++$2)}7')
echo "tag=$TAG_TEMP" >> $GITHUB_OUTPUT
echo "create_tag=true" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.ref }}" == "refs/heads/suite-tagging" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:stage" >> $GITHUB_OUTPUT
echo "build_env=stage" >> $GITHUB_OUTPUT
echo "branch=suite-c4t" >> $GITHUB_OUTPUT
CURRENT_TAG=$(git describe --abbrev=0 --tags)
if [[ $CURRENT_TAG == *"-rc"* ]]; then
TAG_TEMP=$(echo "$CURRENT_TAG"|awk -F'-rc' -v OFS='-rc' '{$2=sprintf("%1d",++$2)}7')
echo "tag=$TAG_TEMP" >> $GITHUB_OUTPUT
echo "create_tag=true" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:dev" >> $GITHUB_OUTPUT
echo "build_env=dev" >> $GITHUB_OUTPUT
echo "branch=dev" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/suite" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:dev" >> $GITHUB_OUTPUT
echo "build_env=dev" >> $GITHUB_OUTPUT
echo "branch=suite" >> $GITHUB_OUTPUT
else
echo "docker_image=$DOCKER_IMAGE_NAME:temp" >> $GITHUB_OUTPUT
echo "branch=temp" >> $GITHUB_OUTPUT
echo "build_env=dev" >> $GITHUB_OUTPUT
fi
- name: Cloud authentication
if: github.event_name == 'push'
id: auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
- name: Create tag
if: ${{ (github.ref == 'refs/heads/suite-tagging') && (github.event_name == 'push') && (steps.setDefaults.outputs.create_tag == 'true') }}
env:
- GITHUB_TOKEN: '${{ secrets.GIT_TAGS_TOKEN }}'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag -a ${{ steps.setDefaults.outputs.tag }} -m "creat tag ${{ steps.setDefaults.outputs.tag }} for staging"
git push --tags
- name: create module docker image
if: ${{ (github.event_name == 'push') }}
run: |
gcloud auth configure-docker --quiet europe-west3-docker.pkg.dev
docker build . -t ${{ env.module_docker_image }}:${{ steps.setDefaults.outputs.branch }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }}
docker push ${{ env.module_docker_image }}:${{ steps.setDefaults.outputs.branch }}
- name: create suite docker image
run: |
docker build . -f Dockerfile_SUITE -t ${{ steps.setDefaults.outputs.docker_image }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }} --build-arg EXPLORER_BRANCH=${{ steps.setDefaults.outputs.branch }} --build-arg WALLET_BRANCH=${{ steps.setDefaults.outputs.branch }}
- name: push and deploy docker
if: ${{ (github.event_name == 'push') }}
run: |
gcloud auth configure-docker --quiet europe-west3-docker.pkg.dev
docker push ${{ steps.setDefaults.outputs.docker_image }}
gcloud run deploy camino-suite-${{ steps.setDefaults.outputs.build_env }} --image ${{ steps.setDefaults.outputs.docker_image }} --region=europe-west1