-
Notifications
You must be signed in to change notification settings - Fork 8
186 lines (181 loc) · 6.43 KB
/
main.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
########################################################################################
# The following secrets are required:
#
# 1. GH_ACCESS_TOKEN - A "fine-grained personal access token" generated through the
# Github UI. It seems like these tokens are scoped to a user, rather than an
# organisation.
#
# The following minimum permissions are required:
# Read - access to metadata
# Read & write - access to actions and code
# 2. GH_USER_NAME - The name (not username) associated with the Git user. e.g. John Smith
# 3. GH_USER_EMAIL - The email associated with the Git user
# 4. NPM_TOKEN - A token for publishing to npm
# 5. DOCKERHUB_USERNAME - Username for publishing to Docker Hub
# 6. DOCKERHUB_TOKEN - Docker Hub publishing token
########################################################################################
name: Continuous Build
on:
push:
branches:
- main
pull_request:
jobs:
documentation:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Check hyperlinks
uses: gaurav-nelson/github-action-markdown-link-check@v1
lint-build-test:
runs-on: ubuntu-latest
name: Build, lint and test
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9.x
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Lint Typescript
run: pnpm run tsc
- name: Lint
run: pnpm run prettier:check && pnpm run eslint:check
- name: Test
run: pnpm run test
e2e:
runs-on: ubuntu-latest
name: E2e tests
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9.x
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Build Docker images
run: pnpm run docker:build
- name: Copy Airnode feed secrets
run: cd packages/e2e/src && cp airnode-feed/secrets.example.env airnode-feed/secrets.env
- name: Copy Signed API secrets
run: cd packages/e2e/src && cp signed-api/secrets.example.env signed-api/secrets.env
- name: Start services
# Start the e2e services in the background and wait a small amount of time for them to start.
run: |
pnpm run --recursive --filter e2e start:data-provider-api &
pnpm run --recursive --filter e2e start:ci:signed-api &
pnpm run --recursive --filter e2e start:ci:airnode-feed &
sleep 5
- name: Run e2e tests
run: pnpm run --recursive --filter e2e test:e2e
required-checks-passed:
name: All required checks passed
runs-on: ubuntu-latest
needs: [documentation, lint-build-test, e2e]
steps:
- run: exit 0
tag-and-release:
name: Tag and release
runs-on: ubuntu-latest
needs: required-checks-passed
# Only tag and release on pushes to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
strategy:
matrix:
node-version: [20]
permissions:
id-token: write
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Configure Git credentials
run: |
git config --global user.name '${{ secrets.GH_USER_NAME }}'
git config --global user.email '${{ secrets.GH_USER_EMAIL }}'
- name: Install Dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Get package.json version
id: get-version
run: echo "version=$(cat package.json | jq -r '.version' | sed 's/^/v/')" >> $GITHUB_OUTPUT
- name: Validate tag
id: validate-tag
run: test "$(git tag -l '${{ steps.get-version.outputs.version }}' | awk '{print $NF}')" = "${{ steps.get-version.outputs.version }}" || echo "new-tag=true" >> $GITHUB_OUTPUT
- name: Tag and release on Github
if: ${{ steps.validate-tag.outputs.new-tag }}
run: pnpm run release:tag
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Publish airnode-feed to npm
if: ${{ steps.validate-tag.outputs.new-tag }}
run: |
npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
cd packages/airnode-feed && pnpm publish --access public
env:
NPM_CONFIG_PROVENANCE: true
- name: Publish signed-api to npm
if: ${{ steps.validate-tag.outputs.new-tag }}
run: |
npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
cd packages/signed-api && pnpm publish --access public
env:
NPM_CONFIG_PROVENANCE: true
- name: Set up Docker Buildx
if: ${{ steps.validate-tag.outputs.new-tag }}
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: ${{ steps.validate-tag.outputs.new-tag }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push airnode-feed Docker image
if: ${{ steps.validate-tag.outputs.new-tag }}
uses: docker/build-push-action@v6
with:
context: .
push: true
target: airnode-feed
tags: |
api3/airnode-feed:latest
api3/airnode-feed:${{ steps.get-version.outputs.version }}
- name: Build and push signed-api Docker image
if: ${{ steps.validate-tag.outputs.new-tag }}
uses: docker/build-push-action@v6
with:
context: .
push: true
target: signed-api
tags: |
api3/signed-api:latest
api3/signed-api:${{ steps.get-version.outputs.version }}