-
Notifications
You must be signed in to change notification settings - Fork 151
204 lines (194 loc) · 6.69 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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: build
on:
push:
branches: [master]
env:
DEFAULT_DEV_VERSION: v0.0.1
jobs:
go:
name: Go
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
id: setup
uses: ./.github/actions/setup
- name: Validate and test Go code
id: go
uses: ./.github/actions/go
with:
COVERAGE_THRESHOLD: ${{ vars.COVERAGE_THRESHOLD }}
e2e:
name: E2E Test
if: ${{ github.ref_name == 'master' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
id: setup
uses: ./.github/actions/setup
with:
cache: "false"
- name: E2E Test
id: e2e
uses: ./.github/actions/e2e
containers:
name: Build and push containers
needs: [go]
runs-on: ubuntu-20.04
environment: dev
outputs:
node-image-ref: ${{ steps.write-output.outputs.node-image-ref }}
node-release-cid: ${{ steps.write-output.outputs.node-release-cid }}
strategy:
matrix:
image-name: ["node"]
steps:
- name: Clear artifacts
uses: kolpav/purge-artifacts-action@v1
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
expire-in: 7days
- name: Checkout
uses: actions/checkout@v2
- name: Build and push container
id: build-and-push
uses: ./.github/actions/build-push
with:
registry: disco-dev.forta.network
name: ${{ matrix.image-name }}
version: ${{ env.DEFAULT_DEV_VERSION }}
aws_access_key: ${{ secrets.DEV_RELEASE_AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.DEV_RELEASE_AWS_SECRET_KEY }}
release_artifacts_bucket_name: dev-forta-releases
- name: Write output values
id: write-output
run: |
echo "::set-output name=${{ matrix.image-name }}-release-cid::${{ steps.build-and-push.outputs.release-cid }}"
echo "::set-output name=${{ matrix.image-name }}-image-ref::${{ steps.build-and-push.outputs.image-reference }}"
publish-hash:
name: Publish Hash to Contract
needs: containers
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Echo Hash
run: |
echo "release-cid=${{ needs.containers.outputs.node-release-cid }}"
- name: Publish Hash
run: |
./scripts/publish-release.sh ${{ needs.containers.outputs.node-release-cid }} ${{ secrets.DEV_PUBLISH_AUTOTASK_KEY }} ${{ secrets.DEV_PUBLISH_AUTOTASK_URL }}
publish-hash-beta:
name: Publish Hash (Beta) to Contract
needs: containers
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Echo Hash
run: |
echo "release-cid=${{ needs.containers.outputs.node-release-cid }}"
- name: Publish Hash
run: |
./scripts/publish-release.sh ${{ needs.containers.outputs.node-release-cid }} ${{ secrets.DEV_PUBLISH_AUTOTASK_KEY }} ${{ secrets.DEV_PUBLISH_BETA_AUTOTASK_URL }}
build-deploy:
name: Build and deploy
needs: [containers]
runs-on: ubuntu-20.04
environment: dev
steps:
- name: Echo Image References
run: |
echo "node=${{ needs.containers.outputs.node-image-ref }}"
- name: Clear artifacts
uses: kolpav/purge-artifacts-action@v1
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
expire-in: 7days
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Create build for revision
run: |
./scripts/build.sh ${{ needs.containers.outputs.node-image-ref }} \
'remote' ${{ needs.containers.outputs.node-release-cid }} ${{ github.sha }} ${{ env.DEFAULT_DEV_VERSION }}
chmod 755 forta
- name: Configure AWS credentials (build artifact -> S3)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_RELEASE_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.DEV_RELEASE_AWS_SECRET_KEY }}
aws-region: us-east-1
- name: Copy build to build artifacts bucket
env:
BUCKET_NAME: ${{ secrets.DEV_BUILD_ARTIFACTS_BUCKET_NAME }}
REVISION: ${{ github.sha }}
run: |
aws s3 cp forta "s3://$BUCKET_NAME/forta-$REVISION"
- name: Prepare Distribution
run: |
mkdir dist
cp forta dist/
cp appspec.yml dist/
cp -R scripts dist/
- name: Zip Distribution
uses: vimtor/action-zip@v1
with:
files: dist/
dest: deploy.zip
- uses: actions/upload-artifact@v1
with:
name: deploy-artifact
path: ${{ github.workspace }}/deploy.zip
- name: Configure AWS credentials (CodeDeploy)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_DEPLOY_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.DEV_DEPLOY_AWS_SECRET_KEY }}
aws-region: us-east-1
- name: AWS CodeDeploy
uses: sourcetoad/aws-codedeploy-action@v1
with:
aws_access_key: ${{ secrets.DEV_DEPLOY_AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.DEV_DEPLOY_AWS_SECRET_KEY }}
aws_region: us-east-1
codedeploy_name: dev-forta-node
codedeploy_group: dev-forta-deploy-group
s3_bucket: dev-forta-codedeploy
s3_folder: dev
directory: ./dist/
release:
name: Release dev
#if: ${{ github.ref_name == 'master' }}
runs-on: ubuntu-20.04
needs: [build-deploy]
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Release
id: release
uses: ./.github/actions/release
with:
version: ${{ env.DEFAULT_DEV_VERSION }}
revision: ${{ github.sha }}
aws_access_key: ${{ secrets.DEV_RELEASE_AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.DEV_RELEASE_AWS_SECRET_KEY }}
build_artifacts_bucket_name: dev-forta-build-artifacts
release_artifacts_bucket_name: dev-forta-releases
release_artifacts_url: https://dist-dev.forta.network/artifacts
dist_base_url: https://dist-dev.forta.network
pgp_key_name: ${{ secrets.DEV_PGP_KEY_NAME }}
pgp_private_key: ${{ secrets.DEV_PGP_PRIVATE_KEY }}
pgp_public_key: ${{ secrets.DEV_PGP_PUBLIC_KEY }}
pgp_passphrase: ${{ secrets.DEV_PGP_PASSPHRASE }}