-
Notifications
You must be signed in to change notification settings - Fork 5
223 lines (199 loc) · 10.9 KB
/
ci.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: CI
on:
push:
branches:
- master
- integration
- experimental*
- release_*
- ci*
- pci*
tags:
- v*
pull_request:
repository_dispatch:
types:
- metwork-trigger*
env:
DOCKER_RUN_OPTIONS: "-v ${{ github.workspace }}:/src -v /buildcache:/buildcache -e GITHUB_REF -e GITHUB_RUN_NUMBER -e GITHUB_SHA -e GITHUB_REPOSITORY"
WORKFLOW_SCRIPTS_DIR: .github/workflows
DOCKER_WORKFLOW_SCRIPTS_DIR: /src/.github/workflows
PAYLOAD_BRANCH: ${{ github.event.client_payload.branch}}
PAYLOAD_OS: ${{ github.event.client_payload.os}}
jobs:
ci_build:
runs-on: [self-hosted, metwork]
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.branch || github.ref }}
- name: set variables
id: SetVariables
run: |
${WORKFLOW_SCRIPTS_DIR}/set_variables.sh
- name: debug env
run: |
env
- name: bootstrap
if: ${{ steps.SetVariables.outputs.branch != 'null' }}
run: |
TARGET_DIR=${{ steps.SetVariables.outputs.target_dir }}
BRANCH=${{ steps.SetVariables.outputs.branch }}
OS_VERSION=${{ steps.SetVariables.outputs.os }}
TAG=${{ steps.SetVariables.outputs.tag }}
DEP_DIR=${{ steps.SetVariables.outputs.dep_dir }}
BUILDIMAGE=${{ steps.SetVariables.outputs.buildimage }}
docker pull ${BUILDIMAGE}
docker run ${DOCKER_RUN_OPTIONS} -e TARGET_DIR=${TARGET_DIR} -e BRANCH=${BRANCH} -e TAG=${TAG} -e DEP_DIR=${DEP_DIR} -e OS_VERSION=${OS_VERSION} --rm ${BUILDIMAGE} /bin/bash -c "${DOCKER_WORKFLOW_SCRIPTS_DIR}/bootstrap_ci.sh"
- name: build
if: ${{ steps.SetVariables.outputs.branch != 'null' }}
id: BuildStep
run: |
TARGET_DIR=${{ steps.SetVariables.outputs.target_dir }}
BRANCH=${{ steps.SetVariables.outputs.branch }}
OS_VERSION=${{ steps.SetVariables.outputs.os }}
TAG=${{ steps.SetVariables.outputs.tag }}
DEP_BRANCH=${{ steps.SetVariables.outputs.dep_branch }}
BUILDIMAGE=${{ steps.SetVariables.outputs.buildimage }}
docker pull ${BUILDIMAGE}
docker run ${DOCKER_RUN_OPTIONS} -e TARGET_DIR=${TARGET_DIR} -e BRANCH=${BRANCH} -e DEP_BRANCH=${DEP_BRANCH} -e TAG=${TAG} -e OS_VERSION=${OS_VERSION} --rm ${BUILDIMAGE} /bin/bash -c "${DOCKER_WORKFLOW_SCRIPTS_DIR}/build.sh"
cat ${{ github.workspace }}/github_output >> ${GITHUB_OUTPUT}
- name: publish buildlogs
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.branch != 'null' }}
uses: thebaptiste/ssh-scp-ssh-pipelines@metwork
env:
REMOTE: ${{ steps.SetVariables.outputs.buildlog_dir }}
LOCAL: ${{ github.workspace }}/buildlogs
with:
host: ${{ secrets.METWORKPUB_HOST }}
user: ${{ secrets.METWORKPUB_USERNAME }}
pass: ${{ secrets.METWORKPUB_PASSWORD }}
port: 22
first_ssh: |
mkdir -p ${REMOTE}
scp: |
'${LOCAL}/*' => ${REMOTE}
- name: integration tests
if: ${{ steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' }}
run: |
TESTIMAGE=${{ steps.SetVariables.outputs.testimage }}
DEP_BRANCH=${{ steps.SetVariables.outputs.dep_branch }}
BRANCH=${{ steps.SetVariables.outputs.branch }}
OS_VERSION=${{ steps.SetVariables.outputs.os }}
docker pull ${TESTIMAGE}
docker run ${DOCKER_RUN_OPTIONS} -e DEP_BRANCH=${DEP_BRANCH} -e BRANCH=${BRANCH} -e OS_VERSION=${OS_VERSION} --rm ${TESTIMAGE} /bin/bash -c "${DOCKER_WORKFLOW_SCRIPTS_DIR}/integration_tests.sh"
- name: publish rpms
if: ${{ github.event_name != 'pull_request' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.branch != 'null' }}
uses: thebaptiste/ssh-scp-ssh-pipelines@metwork
env:
REMOTE: ${{ steps.SetVariables.outputs.rpm_dir }}
LOCAL: ${{ github.workspace }}/rpms
with:
host: ${{ secrets.METWORKPUB_HOST }}
user: ${{ secrets.METWORKPUB_USERNAME }}
pass: ${{ secrets.METWORKPUB_PASSWORD }}
port: 22
first_ssh: |
mkdir -p ${REMOTE}
scp: |
'${LOCAL}/metwork-*.rpm' => ${REMOTE}
- name: createrepo
if: ${{ github.event_name != 'pull_request' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.branch != 'null' }}
uses: thebaptiste/ssh-scp-ssh-pipelines@metwork
env:
REMOTE: ${{ steps.SetVariables.outputs.rpm_dir }}
LOCAL: ${{ github.workspace }}/.github/workflows
with:
host: ${{ secrets.METWORKPUB_HOST }}
user: ${{ secrets.METWORKPUB_USERNAME }}
pass: ${{ secrets.METWORKPUB_PASSWORD }}
port: 22
scp: |
'${LOCAL}/createrepo.sh' => ${REMOTE}
last_ssh: |
cd ${REMOTE}
chmod +x createrepo.sh
./createrepo.sh .
- name: publish doc
if: ${{ github.event_name != 'pull_request' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.branch != 'null' }}
uses: thebaptiste/ssh-scp-ssh-pipelines@metwork
env:
REMOTE: ${{ steps.SetVariables.outputs.doc_dir }}
LOCAL: ${{ github.workspace }}/html_doc
with:
host: ${{ secrets.METWORKPUB_HOST }}
user: ${{ secrets.METWORKPUB_USERNAME }}
pass: ${{ secrets.METWORKPUB_PASSWORD }}
port: 22
first_ssh: |
rm -rf ${REMOTE}
mkdir -p ${REMOTE}
scp: |
'${LOCAL}/*' => ${REMOTE}
- name: clean cache on failure
if: failure()
run: |
sudo rm -f ${{ steps.BuildStep.outputs.buildcache }}
- name: dispatch mfxxx testimage centos6 from centos6
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos6' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos6-testimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: dispatch mfxxx testimage centos7 from centos6
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos6' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos7-testimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: dispatch mfxxx testimage centos8 from centos8
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos8' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos8-testimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: dispatch mfxxx buildimage centos6 from centos6
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos6' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos6-buildimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: dispatch mfxxx buildimage centos7 from centos6
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos6' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos7-buildimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: dispatch mfxxx buildimage centos8 from centos6
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos6' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos8-buildimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: dispatch mfxxx buildimage centos8 from centos8
if: ${{ github.event_name != 'pull_request' && steps.SetVariables.outputs.skip_dispatch == 'false' && steps.SetVariables.outputs.branch != 'null' && steps.BuildStep.outputs.bypass == 'false' && steps.SetVariables.outputs.os == 'centos8' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.METWORK_ACCESS_TOKEN }}
repository: metwork-framework/docker-mfxxx-centos8-buildimage
event-type: metwork-trigger-${{ steps.SetVariables.outputs.branch }}
client-payload: '{"branch": "${{ steps.SetVariables.outputs.branch }}", "os": "${{ steps.SetVariables.outputs.os }}"}'
- name: chown on build outputs
if: always()
run: |
sudo chown -R githubactions:metworkpub .
sudo chmod -R 775 .