-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (142 loc) · 5.46 KB
/
image.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
name: Build
on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
config:
runs-on: self-hosted
outputs:
matrix-packer: ${{ steps.set-matrix.outputs.matrix-packer }}
matrix-windows: ${{ steps.set-matrix.outputs.matrix-windows }}
steps:
- uses: actions/checkout@v2
- name: Set up Node 16.x
uses: actions/setup-node@v1
with:
node-version: "16.x"
- name: Fetch master branch
run: |
git fetch origin master:master
git fetch origin "$GITHUB_REF"
if: "${{ success() && github.ref != 'refs/heads/master' }}"
- name: Install
run: npm ci
- name: Lint
run: npm run lint
- id: set-matrix
name: Identify diff
# Build diff on push (except master)
run: |
build_arg="" && [[ "$GITHUB_EVENT_NAME" =~ "push" && ! "$GITHUB_REF" =~ .*/master ]] && build_arg="--diff";
node ./.github/render_matrix.js --github ${build_arg}
packer:
needs: config
runs-on: self-hosted
timeout-minutes: 120
env:
SCOPE: '${{matrix.scope}}'
CONFIG: '${{matrix.config}}'
H1_TOKEN: '${{secrets.H1_TOKEN}}'
RBX_TOKEN: '${{secrets.RBX_TOKEN}}'
INFLUXDB_HOST: '${{secrets.INFLUXDB_HOST}}'
INFLUXDB_PASSWORD: '${{secrets.INFLUXDB_PASSWORD}}'
INFLUXDB_USER: '${{secrets.INFLUXDB_USER}}'
REDHAT_SECRET: '${{secrets.REDHAT_SECRET}}'
strategy:
fail-fast: false
max-parallel: 5
matrix: ${{fromJson(needs.config.outputs.matrix-packer)}}
steps:
- uses: actions/checkout@v2
- name: "apply workaround for IP conflict bug (TODO: fix me)"
run: sleep $(shuf -i 60-120 -n 1)
- name: Save private SSH key
run: |
echo "$PRIVATE_KEY" | openssl base64 -d > ./resources/secrets/id_rsa;
rm ./resources/ssh/id_rsa*;
cp ./resources/secrets/* ./resources/ssh/;
md5sum ./resources/ssh/*
env:
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
- name: Build Docker image
run: docker build -t recommended-images:${{github.sha}} .
- name: Build Platform image
id: attempt
continue-on-error: true
timeout-minutes: 90
run: |
publish_arg="" && [[ "${GITHUB_BRANCH##*/}" =~ "master" ]] && publish_arg="--publish" ;
docker run --rm -e CI -e H1_TOKEN -e RBX_TOKEN -e SCOPE -e INFLUXDB_HOST -e INFLUXDB_PASSWORD -e INFLUXDB_USER -e REDHAT_SECRET \
-v /var/run/docker.sock:/var/run/docker.sock \
recommended-images:${{github.sha}} \
nodejs buildTestPublish.js --config "$CONFIG" --mode "packer" --cleanup ${publish_arg}
env:
GITHUB_BRANCH: ${{ github.ref }}
- name: Retry build Platform image
timeout-minutes: 90
id: retry
run: |
publish_arg="" && [[ "${GITHUB_BRANCH##*/}" =~ "master" ]] && publish_arg="--publish" ;
docker run --rm -e CI -e H1_TOKEN -e RBX_TOKEN -e SCOPE -e INFLUXDB_HOST -e INFLUXDB_PASSWORD -e INFLUXDB_USER -e REDHAT_SECRET \
-v /var/run/docker.sock:/var/run/docker.sock \
recommended-images:${{github.sha}} \
nodejs buildTestPublish.js --config "$CONFIG" --mode "packer" --cleanup ${publish_arg}
if: ${{ steps.attempt.outcome == 'failure' }}
env:
GITHUB_BRANCH: ${{ github.ref }}
- name: "Report successfully build (1st build) to InfluxDB"
run: ./.github/influx.sh
if: "${{ steps.attempt.outcome == 'success' }}"
env:
INFLUXDB_VALUE: "1"
INFLUXDB_ATTEMPT: "1"
- name: "Report successfully build (2nd build) to InfluxDB"
run: ./.github/influx.sh
if: "${{ steps.attempt.outcome == 'failure' && steps.retry.outcome == 'success' }}"
env:
INFLUXDB_VALUE: "1"
INFLUXDB_ATTEMPT: "2"
- name: "Report failure build to InfluxDB"
run: ./.github/influx.sh
if: "${{ failure() }}"
env:
INFLUXDB_VALUE: "0"
INFLUXDB_ATTEMPT: "2"
windows:
needs: config
timeout-minutes: 720
runs-on: self-hosted
strategy:
fail-fast: false
max-parallel: 1
matrix: ${{fromJson(needs.config.outputs.matrix-windows)}}
env:
SCOPE: '${{matrix.scope}}'
CONFIG: '${{matrix.config}}'
H1_TOKEN: '${{secrets.H1_TOKEN}}'
RBX_TOKEN: '${{secrets.RBX_TOKEN}}'
INFLUXDB_HOST: '${{secrets.INFLUXDB_HOST}}'
INFLUXDB_PASSWORD: '${{secrets.INFLUXDB_PASSWORD}}'
INFLUXDB_USER: '${{secrets.INFLUXDB_USER}}'
REDHAT_SECRET: '${{secrets.REDHAT_SECRET}}'
steps:
- uses: actions/checkout@v2
- name: "apply workaround for IP conflict bug (TODO: fix me)"
run: sleep $(shuf -i 60-120 -n 1)
- name: Save private SSH key
run: echo $PRIVATE_KEY > ./resources/secrets/id_rsa
env:
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
- name: Build Docker image
run: docker build -f Dockerfile.windows -t recommended-images-windows:${{github.sha}} .
- name: Build Platform image
run: |
publish_arg="" && [[ "${GITHUB_BRANCH##*/}" =~ "master" ]] && publish_arg="--publish" ;
docker run --rm -e H1_TOKEN -e SCOPE \
-v /var/run/docker.sock:/var/run/docker.sock \
recommended-images-windows:${{github.sha}} \
nodejs buildTestPublish.js --config "$CONFIG" --mode "windows" --cleanup ${publish_arg}
env:
GITHUB_BRANCH: ${{ github.ref }}