forked from connext/monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (103 loc) · 4.1 KB
/
build-docker-image-and-verify.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
113
114
115
116
117
118
119
120
121
122
# A GitHub Actions workflow to build a docker image for an app.
#
# One-time setup to use this workflow:
# 1. Move this file into ./.github/workflows
# 2. Change APP_NAME variable below to the name of the app.
#
# The image will be built on each push to or pull request on main.
# It will be pushed to the current GitHub repo's Packages.
name: Build and Push Docker Image - Router
on:
push:
branches:
- main
pull_request:
branches:
- main
create:
tag:
- "v*"
env:
# These variables are used by build.sh.
# Comment out the following line to skip pushing the image to your GitHub repo.
DOCKER_REPO: ghcr.io
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Add COMMIT_HASH env property with commit short sha
run: echo "COMMIT_HASH=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
- name: Build and push docker image to GitHub repo
run: |
echo "${{ secrets.SUPER_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
chmod +x ./docker/build-router.sh
./docker/build-router.sh
verify:
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Cache yarn cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --immutable
- name: Build
run: yarn build:all
- name: Test
run: yarn test:all
- name: Get Docker image
run: |
yarn workspace @connext/nxtp-router build
echo "${{ secrets.SUPER_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/connext/nxtp-router:latest
docker tag ghcr.io/connext/nxtp-router:latest nxtp-router:latest
- name: Test Integration
run: yarn test:integration
- name: Print router logs
if: failure()
run: docker container ls && docker container logs --tail 250 router-test
- name: Print graph logs
if: failure()
run: docker container ls && docker container logs --tail 250 graph-node-1337-test && docker container logs --tail 250 graph-node-1338-test
- name: Lint
run: yarn lint:all --max-warnings 0
# -------------------------------------------------------------------------
# PUBLISHING TO NPM
# -------------------------------------------------------------------------
# One-time steps to setup publishing:
# 1. Uncomment the Publish step below and change __PACKAGE_NAME__ to the name of
# the package you want to publish. (Include the @scope, if any.)
# 2. Create a secret in your github repo named NPM_TOKEN to authenticate to npm.
#
# To publish a version (replace "1.2.3" with your version number), run:
# yarn version:all 1.2.3
# git push --follow-tags
#
# See https://github.com/jtbennett/create-ts-project/blob/main/docs/publishing-to-npm.md
# for details.
# -------------------------------------------------------------------------
- name: Publish
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn workspace @connext/nxtp-utils npm publish --access public
yarn workspace @connext/nxtp-contracts npm publish --access public
yarn workspace @connext/nxtp-txservice npm publish --access public
yarn workspace @connext/nxtp-sdk npm publish --access public