-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (79 loc) · 3.28 KB
/
build.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
name: build
on:
workflow_dispatch: {}
push:
branches: [ main, develop ]
env:
PROJECT_ID: bright-meridian-316511
jobs:
build:
runs-on: ubuntu-latest
steps:
# - name: cancel previous runs
# uses: styfle/[email protected]
# with:
# access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Yarn
run: corepack enable
# Yarn dependencies cannot be cached until yarn is installed
# WORKAROUND: https://github.com/actions/setup-node/issues/531
- name: Extract cached dependencies
uses: actions/setup-node@v4
with:
cache: yarn
- name: env
id: env
run: |
echo "::set-output name=tag::$(git rev-parse --short HEAD)"
if [ "$REF" = "refs/heads/main" ]; then
echo "::set-output name=app_env::prod"
echo "::set-output name=wc_project_id::475eff0658d0f3300ca18971418d261b"
echo "::set-output name=enable_demo_features::false"
echo "::set-output name=squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/v/v1/graphql"
echo "::set-output name=app_domain::app.subsquid.io"
else
echo "::set-output name=app_env::dev"
echo "::set-output name=wc_project_id::ec2facac9eaaca7cc0584baadc935c01"
echo "::set-output name=enable_demo_features::true"
echo "::set-output name=squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/v/v1/graphql"
echo "::set-output name=app_domain::app.devsquid.net"
fi
env:
REF: ${{ github.ref }}
- run: yarn install --immutable
- run: yarn build
env:
APP_ENV: ${{ steps.env.outputs.app_env }}
APP_VERSION: ${{ steps.env.outputs.tag }}
WALLET_CONNECT_PROJECT_ID: ${{ steps.env.outputs.wc_project_id }}
ENABLE_DEMO_FEATURES: ${{ steps.env.outputs.enable_demo_features }}
NETWORK: ${{ steps.env.outputs.network }}
SQUID_API_URL: ${{ steps.env.outputs.squid_api_url }}
# Build and push images to Google Container Registry
- name: Build image
run: docker build --progress=plain -t "gcr.io/${PROJECT_ID}/subsquid-network-app-${APP_ENV}:${TAG}" -t "gcr.io/${PROJECT_ID}/subsquid-network-app-${APP_ENV}:latest" .
env:
APP_ENV: ${{ steps.env.outputs.app_env }}
TAG: ${{ steps.env.outputs.tag }}
- id: auth
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
# steps for push images to gcr
- name: 'gcloud cli --> docker credential helper'
run: gcloud auth configure-docker -q
- name: Push image
run: |
docker push "gcr.io/${PROJECT_ID}/subsquid-network-app-${APP_ENV}:${TAG}"
docker push "gcr.io/${PROJECT_ID}/subsquid-network-app-${APP_ENV}:latest"
env:
APP_ENV: ${{ steps.env.outputs.app_env }}
TAG: ${{ steps.env.outputs.tag }}