Skip to content

Commit 06ee0f2

Browse files
committed
new image build workflow
1 parent 03732bc commit 06ee0f2

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed

.github/workflows/fatimage.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

2-
name: Build fat image
2+
name: Build nightly fat image
33
on:
44
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *' # Run at midnight
7+
58
jobs:
69
openstack:
710
name: openstack-imagebuild

.github/workflows/imagebuild.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
2+
name: Build new image
3+
on:
4+
workflow_dispatch:
5+
jobs:
6+
openstack:
7+
name: openstack-imagebuild
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.build }} # to branch/PR + OS + build
10+
cancel-in-progress: true
11+
runs-on: ubuntu-22.04
12+
strategy:
13+
fail-fast: false # allow other matrix jobs to continue even if one fails
14+
matrix: # build RL8+OFED, RL9+OFED, RL9+OFED+CUDA versions
15+
os_version:
16+
- RL8
17+
- RL9
18+
build:
19+
- openstack.openhpc-ofed
20+
- openstack.openhpc-cuda
21+
exclude:
22+
- os_version: RL8
23+
build: openstack.openhpc-cuda
24+
env:
25+
ANSIBLE_FORCE_COLOR: True
26+
OS_CLOUD: openstack
27+
CI_CLOUD: ${{ vars.CI_CLOUD }}
28+
steps:
29+
- uses: actions/checkout@v2
30+
31+
- name: Setup ssh
32+
run: |
33+
set -x
34+
mkdir ~/.ssh
35+
echo "${{ secrets[format('{0}_SSH_KEY', vars.CI_CLOUD)] }}" > ~/.ssh/id_rsa
36+
chmod 0600 ~/.ssh/id_rsa
37+
shell: bash
38+
39+
- name: Add bastion's ssh key to known_hosts
40+
run: cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
41+
shell: bash
42+
43+
- name: Install ansible etc
44+
run: dev/setup-env.sh
45+
46+
- name: Write clouds.yaml
47+
run: |
48+
mkdir -p ~/.config/openstack/
49+
echo "${{ secrets[format('{0}_CLOUDS_YAML', vars.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
50+
shell: bash
51+
52+
- name: Setup environment
53+
run: |
54+
. venv/bin/activate
55+
. environments/.stackhpc/activate
56+
57+
- name: Build fat image with packer
58+
id: packer_build
59+
run: |
60+
. venv/bin/activate
61+
. environments/.stackhpc/activate
62+
cd packer/
63+
packer init .
64+
PACKER_LOG=1 packer build -on-error=${{ vars.PACKER_ON_ERROR }} -only=${{ matrix.build }} -var-file=$PKR_VAR_environment_root/${{ vars.CI_CLOUD }}.pkrvars.hcl openstack.pkr.hcl
65+
env:
66+
PKR_VAR_os_version: ${{ matrix.os_version }}
67+
68+
- name: Get created image names from manifest
69+
id: manifest
70+
run: |
71+
. venv/bin/activate
72+
IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json)
73+
while ! openstack image show -f value -c name $IMAGE_ID; do
74+
sleep 5
75+
done
76+
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
77+
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
78+
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
79+
80+
- name: Download image
81+
run: |
82+
. venv/bin/activate
83+
sudo mkdir /mnt/images
84+
sudo chmod 777 /mnt/images
85+
openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-name }}
86+
87+
- name: Set up QEMU
88+
uses: docker/setup-qemu-action@v3
89+
90+
- name: install libguestfs
91+
run: |
92+
sudo apt -y update
93+
sudo apt -y install libguestfs-tools
94+
95+
- name: mkdir for mount
96+
run: sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
97+
98+
- name: mount qcow2 file
99+
run: sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
100+
101+
- name: Run Trivy vulnerability scanner
102+
uses: aquasecurity/[email protected]
103+
with:
104+
scan-type: fs
105+
scan-ref: "${{ steps.manifest.outputs.image-name }}"
106+
scanners: "vuln"
107+
format: sarif
108+
output: "${{ steps.manifest.outputs.image-name }}.sarif"
109+
# turn off secret scanning to speed things up
110+
111+
- name: Upload Trivy scan results to GitHub Security tab
112+
uses: github/codeql-action/upload-sarif@v3
113+
with:
114+
sarif_file: "${{ steps.manifest.outputs.image-name }}.sarif"
115+
category: "${{ matrix.os_version }}-${{ matrix.build }}"
116+
117+
- name: Fail if scan has CRITICAL vulnerabilities
118+
uses: aquasecurity/[email protected]
119+
with:
120+
scan-type: fs
121+
scan-ref: "${{ steps.manifest.outputs.image-name }}"
122+
scanners: "vuln"
123+
format: table
124+
exit-code: '1'
125+
severity: 'CRITICAL'
126+
ignore-unfixed: true

0 commit comments

Comments
 (0)