-
Notifications
You must be signed in to change notification settings - Fork 4
108 lines (87 loc) · 3.33 KB
/
release.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
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
name: Release
on:
push:
branches:
- master
- development
env:
DOCKER_REGISTRY_HOST: europe-west1-docker.pkg.dev
GCP_PROJECT: carmine-api-381920
jobs:
release:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm i -f
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.DAVID_NPM_TOKEN }}
run: npx semantic-release
- name: Auth Google Cloud SDK
uses: google-github-actions/auth@v2
with:
project_id: carmine-api-381920
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: carmine-api-381920
- name: Configure Docker to use gcloud as a credential helper
run: |
gcloud auth configure-docker $DOCKER_REGISTRY_HOST
- name: Build Docker image
id: build
run: |
VERSION=$(npx -c 'echo $npm_package_version')
echo "VERSION=$VERSION" >> $GITHUB_ENV
docker build -t $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-mainnet:$VERSION -f Dockerfile.mainnet .
docker build -t $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-testnet:$VERSION -f Dockerfile.testnet .
- name: Push Docker image
run: |
docker push $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-mainnet:${{ env.VERSION }}
docker push $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-testnet:${{ env.VERSION }}
devdeploy:
if: github.ref == 'refs/heads/development'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm i -f
- name: Auth Google Cloud SDK
uses: google-github-actions/auth@v2
with:
project_id: carmine-api-381920
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: carmine-api-381920
- name: Configure Docker to use gcloud as a credential helper
run: |
gcloud auth configure-docker $DOCKER_REGISTRY_HOST
- name: Build Docker image
id: build
run: |
IMAGE_ID=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 10)
echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV
docker build -t $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-mainnet:$IMAGE_ID -f Dockerfile.mainnet .
docker build -t $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-testnet:$IMAGE_ID -f Dockerfile.testnet .
- name: Push Docker image
run: |
docker push $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-mainnet:${{ env.IMAGE_ID }}
docker push $DOCKER_REGISTRY_HOST/$GCP_PROJECT/docker-repository/app-testnet:${{ env.IMAGE_ID }}