-
Notifications
You must be signed in to change notification settings - Fork 113
44 lines (38 loc) · 1.49 KB
/
packer-templates.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
name: packer-templates
on:
workflow_dispatch:
push:
branches-ignore:
- main
paths:
- "*.json"
- .github/workflows/packer-templates.yml
permissions: read-all
jobs:
packer-templates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
submodules: true
- name: Download Packer
run: |
set -euxo pipefail
PACKER_LATEST_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')
curl -s "https://releases.hashicorp.com/packer/${PACKER_LATEST_VERSION}/packer_${PACKER_LATEST_VERSION}_linux_amd64.zip" --output /tmp/packer_linux_amd64.zip
sudo unzip -o /tmp/packer_linux_amd64.zip -d /usr/local/bin/
packer plugins install github.com/hashicorp/ansible
packer plugins install github.com/hashicorp/qemu
packer plugins install github.com/hashicorp/vagrant
packer plugins install github.com/hashicorp/virtualbox
- name: Validate Packer templates
run: |
IFS=$'\n'
mkdir -pv packer_cache/virtio-win
for FILE in *.json; do
echo "*** ${FILE}"
awk -F\" '/"_comment[0-9]*"/ { gsub("packer build","packer validate",$4); print $4 }' "${FILE}" | while IFS= read -r PACKER_VALIDATE_RUN ; do
echo "* ${PACKER_VALIDATE_RUN}"
eval "${PACKER_VALIDATE_RUN}"
done
done