forked from perfsonar/sca-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (167 loc) · 7.26 KB
/
sca-auth-workflow.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
name: sca-auth-workflow
on:
workflow_dispatch:
inputs:
BUILD_VARS_JSON:
description: 'Build var json file'
required: true
workflow_run:
workflows: "Create Artifacts and pass runid"
branches: 'github-workflow'
types:
- completed
jobs:
build-sca-auth:
runs-on: ubuntu-latest
steps:
- name: Capture start date and time
id: start_time
run: echo "start_time=$(date -u)" >> $GITHUB_ENV
- name: Add start time to build_vars.json
run: |
modified_json=$(echo '${{ github.event.inputs.BUILD_VARS_JSON }}' | jq '.buildstats += { "${{ github.event.repository.name }}-start": "${{ env.start_time }}" }' )
BUILD_VARS_JSON=$(echo "$modified_json" | jq -c '.')
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON" >> $GITHUB_ENV
echo "**** next next ****"
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON"
- name: Get build vars from input file
id: extract_build_vars
run: |
BUILD_OS=$(echo "$BUILD_VARS_JSON" | jq -r '.buildstats.OS' )
BUILD_BRANCH=$(echo "$BUILD_VARS_JSON" | jq -r '.buildstats.BUILD_BRANCH' )
BUILD_TYPE=$(echo "$BUILD_VARS_JSON" | jq -r '.buildstats.BUILD_TYPE' )
echo "BUILD_OS=$BUILD_OS" >> $GITHUB_ENV
echo "BUILD_BRANCH=$BUILD_BRANCH" >> $GITHUB_ENV
echo "BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV
- name: Check out Repo
uses: actions/checkout@v4
with:
ref: ${{ env.BUILD_BRANCH}}
- name: Fetch workflow script from projects
env:
github-token: ${{ secrets.GIT_ACTIONS }}
run: |
git clone https://github.com/cs1867/project.git project
case "${{ env.BUILD_OS }}" in
'ol8'|'el9')
cp project/toolbox/workflows/github-workflow-el-skip-install.sh .
;;
'd11'|'d12'|'u20'|'u22'|'u24')
cp project/toolbox/workflows/github-db-workflow.sh .
;;
esac
- name: Extract dependencies
id: extract_deps
run: |
echo "$BUILD_VARS_JSON" | jq -r '.repos[] | select(.name == "${{ github.event.repository.name }}") | .deps[]' > deps.txt
case "${{ env.BUILD_OS }}" in
'u20'|'u24')
sed -i '/minor-packages/d' deps.txt
;;
*)
echo "No specific packages to remove"
;;
esac
echo "Dependencies:"
cat deps.txt
- name: Download artifacts
run: |
mkdir -p artifacts
while IFS= read -r repo; do
echo "Downloading artifact for $repo"
run_id=$(echo "$BUILD_VARS_JSON" | jq -r ".buildids | .[\"$repo\"]")
echo "rund id $run_id"
gh run download $run_id --repo cs1867/$repo -D artifacts/$repo --name "$repo-${{ env.BUILD_OS }}"
artifact_path="artifacts/$repo"
pwd
echo "list artifact path"
ls -al "$artifact_path"
case "${{ env.BUILD_OS }}" in
'ol8'|'el9')
mkdir -p artifacts/RPMS
echo "copy to the artifacts RPM dir"
cp "$artifact_path"/RPMS/*.rpm artifacts/RPMS
;;
'd11'|'d12'|'u20'|'u22'|'u24')
mkdir -p artifacts/DEBS
echo "copy to the artifacts DEBS dir"
cp -r "$artifact_path"/* artifacts/DEBS
echo "list artifacts DEBS dir"
ls -al artifacts/DEBS/*
;;
esac
done < deps.txt
env:
GITHUB_TOKEN: ${{ secrets.GIT_ACTIONS }}
- name: run docker oneshot builder and github-actions-workflow.sh
run: |
case "${{ env.BUILD_OS }}" in
'ol8'|'el9')
curl -s https://raw.githubusercontent.com/perfsonar/docker-oneshot-builder/main/build | sh -s - --run github-workflow-el-skip-install.sh . '${{ env.BUILD_OS }}'
;;
'd11'|'d12'|'u20'|'u22'|'u24')
curl -s https://raw.githubusercontent.com/perfsonar/docker-oneshot-builder/main/build | sh -s - --run github-db-workflow.sh . '${{ env.BUILD_OS }}'
;;
esac
- uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-${{ env.BUILD_OS }}
path: unibuild-repo
retention-days: 5
- name: Delete current repo from build
id: modify_json
run: |
modified_json=$(echo "$BUILD_VARS_JSON" | jq 'del(.repos[0])')
echo "Modified JSON:"
echo "$modified_json" | jq .
BUILD_VARS_JSON=$(echo "$modified_json" | jq -c '.')
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON" >> $GITHUB_ENV
echo "**** next next ****"
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON"
- uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-${{ env.BUILD_OS }}
path: unibuild-repo
retention-days: 5
- name: Add GitHub run ID to buildids
id: add_run_id
run: |
GITHUB_RUN_ID=${{ github.run_id }}
modified_json=$(echo "$BUILD_VARS_JSON" | jq --arg run_id "$GITHUB_RUN_ID" '.buildids."${{ github.event.repository.name }}" = $run_id')
echo "Modified JSON with GitHub run ID:"
echo "$modified_json" | jq .
BUILD_VARS_JSON=$(echo "$modified_json" | jq -c '.')
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON" >> $GITHUB_ENV
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON"
- name: Look up the next repo name to build
id: extract_repo_name
run: |
echo "BUILD_VARS_JSON value is: $BUILD_VARS_JSON"
NEXTREPO=$(echo "$BUILD_VARS_JSON" | jq -r '.repos[0].name' )
echo "NEXTREPO=$NEXTREPO" >> $GITHUB_ENV
- name: Display NEXTREPO value
run: echo "The value of NEXTREPO is $NEXTREPO"
- name: Capture end date and time
id: end_time
run: echo "end_time=$(date -u)" >> $GITHUB_ENV
- name: Add end time to build_vars.json
run: |
modified_json=$(echo "$BUILD_VARS_JSON" | jq '.buildstats += { "${{ github.event.repository.name }}-end": "${{ env.end_time }}" }' )
BUILD_VARS_JSON=$(echo "$modified_json" | jq -c '.')
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON" >> $GITHUB_ENV
echo "BUILD_VARS_JSON=$BUILD_VARS_JSON"
- name: Pass workflow
if: env.BUILD_TYPE == 'FULL'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GIT_ACTIONS }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'cs1867',
repo: '${{ env.NEXTREPO}}',
workflow_id: '${{ env.NEXTREPO}}-workflow.yml',
ref: 'github-workflow',
inputs: {
BUILD_VARS_JSON: '${{ env.BUILD_VARS_JSON}}'
}
})