-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
test: | ||
name: Build VM images | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install tools | ||
run: brew install qemu oras | ||
|
||
# Docker doesn't work on macos-latest | ||
# cf. https://github.com/docker/login-action/issues/93 | ||
- name: Login to GitHub Container Registry | ||
run: oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io | ||
|
||
- name: Build Ubuntu 22.04 | ||
run: | | ||
packer build -force templates/ubuntu-2204.json | ||
mkdir ubuntu-2204 | ||
tar xvf output-vagrant/package.box -C ubuntu-2204 | ||
qemu-img convert -O raw ubuntu-2204/box-disk001.vmdk ubuntu-2204/ubuntu-2204.img | ||
- name: Push Ubuntu 22.04 | ||
run: | | ||
mv ubuntu-2204/box-disk001.vmdk ubuntu-2204/ubuntu-2204.vmdk | ||
cd ubuntu-2204 | ||
gzip ubuntu-2204.img ubuntu-2204.vmdk | ||
oras push ghcr.io/${{ github.repository_owner }}/trivy-test-vm-images:ubuntu-2204 \ | ||
--artifact-type application/vnd.aquasec.trivy.config \ | ||
ubuntu-2204.img.gz:application/vnd.aquasec.trivy.vm.image.v1+gzip \ | ||
ubuntu-2204.vmdk.gz:application/vnd.aquasec.trivy.vm.vmdk.v1+gzip | ||
cd .. && rm -rf ubuntu-2204 | ||
- name: Build Amazon Linux 2 | ||
run: | | ||
packer build -force templates/amazonlinux-2.json | ||
mkdir amazonlinux-2 | ||
tar xvf output-vagrant/package.box -C amazonlinux-2 | ||
qemu-img convert -O raw amazonlinux-2/box-disk001.vmdk amazonlinux-2/amazon-2.img | ||
- name: Push Amazon Linux 2 | ||
run: | | ||
mv amazonlinux-2/box-disk001.vmdk amazonlinux-2/amazon-2.vmdk | ||
cd amazonlinux-2 | ||
gzip amazon-2.img amazon-2.vmdk | ||
oras push ghcr.io/${{ github.repository_owner }}/trivy-test-vm-images:amazon-2 \ | ||
--artifact-type application/vnd.aquasec.trivy.config \ | ||
amazon-2.img.gz:application/vnd.aquasec.trivy.vm.image.v1+gzip \ | ||
amazon-2.vmdk.gz:application/vnd.aquasec.trivy.vm.vmdk.v1+gzip | ||
cd .. && rm -rf amazonlinux-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"builders": [ | ||
{ | ||
"communicator": "ssh", | ||
"source_path": "bento/amazonlinux-2", | ||
"box_version": "v1.3", | ||
"provider": "virtualbox", | ||
"add_force": true, | ||
"type": "vagrant" | ||
} | ||
], | ||
"provisioners": [{ | ||
"type": "shell", | ||
"inline": [ | ||
"sudo yum -y install httpd git" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"builders": [ | ||
{ | ||
"communicator": "ssh", | ||
"source_path": "ubuntu/jammy64", | ||
"box_version": "v20230608.0.0", | ||
"provider": "virtualbox", | ||
"add_force": true, | ||
"type": "vagrant" | ||
} | ||
], | ||
"provisioners": [{ | ||
"type": "shell", | ||
"inline": [ | ||
"sudo apt-get -y update", | ||
"sudo apt-get -y install git" | ||
] | ||
}] | ||
} |