-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (92 loc) · 3.87 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
97
98
99
100
101
102
103
104
105
106
107
108
name: build
on:
workflow_dispatch: {}
push:
branches: [ main, develop ]
env:
PROJECT_ID: bright-meridian-316511
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
network: [mainnet, tethys]
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=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/graphql"
echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet/graphql"
echo "::set-output name=enable_demo_features::false"
else
echo "::set-output name=app_env::dev"
echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/v/v3/graphql"
echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet/v/v3/graphql"
echo "::set-output name=enable_demo_features::true"
fi
if [ "$NETWORK" = "mainnet" ]; then
echo "::set-output name=wc_project_id::475eff0658d0f3300ca18971418d261b"
else
echo "::set-output name=wc_project_id::ec2facac9eaaca7cc0584baadc935c01"
fi
env:
REF: ${{ github.ref }}
NETWORK: ${{ matrix.network }}
- run: yarn install --immutable
# Check compile errors before build
- run: yarn tsc
- 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: ${{ matrix.network }}
TESTNET_SQUID_API_URL: ${{ steps.env.outputs.testnet_squid_api_url }}
MAINNET_SQUID_API_URL: ${{ steps.env.outputs.mainnet_squid_api_url }}
NODE_ENV: production
# Build and push images to Google Container Registry
- name: Build image
run: docker build --progress=plain -t "gcr.io/${PROJECT_ID}/subsquid-network-app-${NETWORK}-${APP_ENV}:${TAG}" -t "gcr.io/${PROJECT_ID}/subsquid-network-app-${NETWORK}-${APP_ENV}:latest" .
env:
APP_ENV: ${{ steps.env.outputs.app_env }}
NETWORK: ${{ matrix.network }}
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-${NETWORK}-${APP_ENV}:${TAG}"
docker push "gcr.io/${PROJECT_ID}/subsquid-network-app-${NETWORK}-${APP_ENV}:latest"
env:
APP_ENV: ${{ steps.env.outputs.app_env }}
NETWORK: ${{ matrix.network }}
TAG: ${{ steps.env.outputs.tag }}