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
--- | |
# Check that declared Packer images are valid. | |
name: Validate Packer images | |
'on': | |
- push | |
- pull_request | |
permissions: | |
contents: read | |
jobs: | |
validate: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install prerequisites | |
run: | | |
sudo apt update -y | |
sudo apt install -y packer | |
packer plugins install github.com/hashicorp/docker | |
- name: Validate Packer images | |
run: | | |
error=0 | |
for decl in */packer.json; do | |
pushd "$(dirname "$decl")" | |
if ! packer validate packer.json; then | |
echo -n "::error file=$decl,line=1,title=packer validate failed" | |
echo "::Packer validation failed for $decl." | |
error=1 | |
fi | |
popd | |
done | |
exit $error |