-
Notifications
You must be signed in to change notification settings - Fork 81
77 lines (66 loc) · 2.14 KB
/
build.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
name: build
on:
push:
branches:
- new-docs
- develop
- master
paths:
- .github/workflows/build.yaml
- mkdocs.yml
- Dockerfile
- docs/**
- src/**
- docusaurus.config.js
workflow_dispatch: {}
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT }}
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
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: env
id: env
run: |
echo "::set-output name=tag::$(git rev-parse --short HEAD)"
if [ "$REF" = "refs/heads/master" ]; then
echo "::set-output name=release_version::prod"
else
echo "::set-output name=release_version::dev"
fi
env:
REF: ${{ github.ref }}
# Setup gcloud CLI
- uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.GCP_PROJECT }}
service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
# Build the Docker image
- name: Build
run: |-
docker build \
--tag "gcr.io/${PROJECT_ID}/subsquid-docs-${RELEASE_VERSION}:${TAG}" \
--tag "gcr.io/${PROJECT_ID}/subsquid-docs-${RELEASE_VERSION}:latest" \
.
env:
RELEASE_VERSION: ${{ steps.env.outputs.release_version }}
TAG: ${{ steps.env.outputs.tag }}
# Push the Docker image to Google Container Registry
- name: Publish
run: |-
docker push "gcr.io/${PROJECT_ID}/subsquid-docs-${RELEASE_VERSION}:${TAG}"
docker push "gcr.io/${PROJECT_ID}/subsquid-docs-${RELEASE_VERSION}:latest"
env:
RELEASE_VERSION: ${{ steps.env.outputs.release_version }}
TAG: ${{ steps.env.outputs.tag }}