Skip to content

Commit 02fa0b6

Browse files
committed
finish nightly build workflow
1 parent 7183fcc commit 02fa0b6

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

.github/workflows/fatimage.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,157 @@ on:
1414
- cron: '0 0 * * *' # Run at midnight
1515

1616
jobs:
17+
openstack:
18+
name: openstack-imagebuild
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.build }} # to branch/PR + OS + build
21+
cancel-in-progress: true
22+
runs-on: ubuntu-22.04
23+
strategy:
24+
fail-fast: false # allow other matrix jobs to continue even if one fails
25+
matrix: # build RL8+OFED, RL9+OFED, RL9+OFED+CUDA versions
26+
os_version:
27+
- RL8
28+
- RL9
29+
build:
30+
- openstack.rocky-latest
31+
- openstack.rocky-latest-cuda
32+
exclude:
33+
- os_version: RL8
34+
build: openstack.rocky-latest-cuda
35+
36+
env:
37+
ANSIBLE_FORCE_COLOR: True
38+
OS_CLOUD: openstack
39+
CI_CLOUD: ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
40+
steps:
41+
- uses: actions/checkout@v2
42+
43+
- name: Record settings for CI cloud
44+
run: |
45+
echo CI_CLOUD: ${{ env.CI_CLOUD }}
46+
47+
- name: Setup ssh
48+
run: |
49+
set -x
50+
mkdir ~/.ssh
51+
echo "${{ secrets[format('{0}_SSH_KEY', env.CI_CLOUD)] }}" > ~/.ssh/id_rsa
52+
chmod 0600 ~/.ssh/id_rsa
53+
shell: bash
54+
55+
- name: Add bastion's ssh key to known_hosts
56+
run: cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
57+
shell: bash
58+
59+
- name: Install ansible etc
60+
run: dev/setup-env.sh
61+
62+
- name: Write clouds.yaml
63+
run: |
64+
mkdir -p ~/.config/openstack/
65+
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
66+
shell: bash
67+
68+
- name: Setup environment
69+
run: |
70+
. venv/bin/activate
71+
. environments/.stackhpc/activate
72+
73+
- name: Build fat image with packer
74+
id: packer_build
75+
run: |
76+
set -x
77+
. venv/bin/activate
78+
. environments/.stackhpc/activate
79+
cd packer/
80+
packer init .
81+
82+
PACKER_LOG=1 packer build \
83+
-on-error=${{ vars.PACKER_ON_ERROR }} \
84+
-only=${{ matrix.build }} \
85+
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
86+
openstack.pkr.hcl
87+
88+
env:
89+
PKR_VAR_os_version: ${{ matrix.os_version }}
90+
91+
- name: Get created image names from manifest
92+
id: manifest
93+
run: |
94+
. venv/bin/activate
95+
IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json)
96+
while ! openstack image show -f value -c name $IMAGE_ID; do
97+
sleep 5
98+
done
99+
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
100+
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
101+
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
102+
103+
- name: Delete old latest image
104+
run: |
105+
. venv/bin/activate
106+
IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
107+
if [ "$IMAGE_COUNT" -gt 1 ]; then
108+
OLD_IMAGE_ID=$(openstack image list --sort created_at:asc --name "${{ steps.manifest.outputs.image-name }}" -f value -c ID | head -n 1)
109+
openstack image delete "$OLD_IMAGE_ID"
110+
else
111+
echo "Only one image exists, skipping deletion."
112+
fi
113+
114+
- name: Download image
115+
run: |
116+
. venv/bin/activate
117+
sudo mkdir /mnt/images
118+
sudo chmod 777 /mnt/images
119+
openstack image unset --property signature_verified "${{ steps.manifest.outputs.image-name }}"
120+
openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-name }}
121+
122+
- name: Set up QEMU
123+
uses: docker/setup-qemu-action@v3
124+
125+
- name: install libguestfs
126+
run: |
127+
sudo apt -y update
128+
sudo apt -y install libguestfs-tools
129+
130+
- name: mkdir for mount
131+
run: sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
132+
133+
- name: mount qcow2 file
134+
run: sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
135+
136+
- name: Run Trivy vulnerability scanner
137+
uses: aquasecurity/[email protected]
138+
with:
139+
scan-type: fs
140+
scan-ref: "${{ steps.manifest.outputs.image-name }}"
141+
scanners: "vuln"
142+
format: sarif
143+
output: "${{ steps.manifest.outputs.image-name }}.sarif"
144+
# turn off secret scanning to speed things up
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
148+
- name: Upload Trivy scan results to GitHub Security tab
149+
uses: github/codeql-action/upload-sarif@v3
150+
with:
151+
sarif_file: "${{ steps.manifest.outputs.image-name }}.sarif"
152+
category: "${{ matrix.os_version }}-${{ matrix.build }}"
153+
154+
- name: Fail if scan has CRITICAL vulnerabilities
155+
uses: aquasecurity/[email protected]
156+
with:
157+
scan-type: fs
158+
scan-ref: "${{ steps.manifest.outputs.image-name }}"
159+
scanners: "vuln"
160+
format: table
161+
exit-code: '1'
162+
severity: 'CRITICAL'
163+
ignore-unfixed: true
164+
17165
upload:
18166
name: upload-nightly-targets
167+
needs: openstack
19168
concurrency:
20169
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.image }}-${{ matrix.target_cloud }}
21170
cancel-in-progress: true

0 commit comments

Comments
 (0)