4 # yamllint disable-line rule:truthy
9 description: "Branch that change is against"
14 description: "The ID for the change"
18 description: "The Gerrit number"
22 description: "URL to the change"
26 description: "Type of Gerrit event"
29 GERRIT_PATCHSET_NUMBER:
30 description: "The patch number for the change"
33 GERRIT_PATCHSET_REVISION:
34 description: "The revision sha"
38 description: "Project in Gerrit"
41 default: releng/builder
43 description: "Gerrit refspec of change"
50 PACKER_VERSION: "1.9.1"
53 group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
54 cancel-in-progress: true
58 runs-on: ubuntu-latest
61 uses: lfit/gerrit-review-action@v0.4
63 host: ${{ vars.GERRIT_SERVER }}
64 username: ${{ vars.GERRIT_SSH_USER }}
65 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
66 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
67 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
68 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
71 - name: Allow replication
76 runs-on: ubuntu-latest
78 - uses: lfit/checkout-gerrit-change-action@v0.4
80 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
82 - name: Clone git submodules
83 run: git submodule update --init
85 uses: hashicorp/setup-packer@main
88 version: ${{ env.PACKER_VERSION }}
89 - name: Create cloud-env file required for packer
90 id: create-cloud-env-file
93 echo "${{ secrets.CLOUDS_ENV_B64 }}" | base64 --decode > "${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl"
94 - name: Create cloud.yaml file for openstack client
95 id: create-cloud-yaml-file
98 mkdir -p "$HOME/.config/openstack"
99 echo "${{ secrets.CLOUDS_YAML_B64 }}" | base64 --decode > "$HOME/.config/openstack/clouds.yaml"
100 - uses: actions/setup-python@v4
103 python-version: "3.11"
104 - name: Install openstack deps
105 id: install-openstack-deps
107 python -m pip install --upgrade pip
108 pip install python-openstackclient
110 - uses: dorny/paths-filter@v2
113 base: ${{ inputs.GERRIT_BRANCH }}
114 ref: ${{ inputs.GERRIT_REFSPEC }}
118 - if: steps.changes.outputs.src == 'true'
123 varfiles=(common-packer/vars/*.pkrvars.hcl)
124 templates=(templates/*.pkr.hcl)
126 mkdir -p "${GITHUB_WORKSPACE}/logs"
127 PACKER_LOGS_DIR="${GITHUB_WORKSPACE}/logs"
129 for varfile in "${varfiles[@]}"; do
130 if [[ "$varfile" == *"cloud-env.json"* ]] || \
131 [[ "$varfile" == "vars/*.json" ]] || \
132 [[ "$varfile" == *"cloud-env.pkrvars.hcl"* ]] || \
133 [[ "$varfile" == *"cloud-env-aws.pkrvars.hcl"* ]] || \
134 [[ "$varfile" == "vars/*.pkrvars.hcl" ]]; then
138 echo "-----> Test var: $varfile"
139 for template in "${templates[@]}"; do
140 if [[ "$template" == *"variables.pkr.hcl"* ]] || \
141 [[ "$template" == *"variables.auto.pkr.hcl"* ]]; then
145 if [[ "${template#*.}" == "pkr.hcl" ]]; then
146 echo "packer init $template ..."
147 packer init "$template"
150 export PACKER_LOG="yes"
151 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log"
152 if output=$(OS_CLOUD=${{ env.OS_CLOUD }} packer validate \
153 -var-file="${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl" \
154 -var-file="$varfile" "$template"); then
155 echo "$template: $output"
157 echo "$template: $output"
165 needs: [prepare, packer-validator]
166 runs-on: ubuntu-latest
168 - uses: technote-space/workflow-conclusion-action@v3
170 uses: lfit/gerrit-review-action@v0.4
172 host: ${{ vars.GERRIT_SERVER }}
173 username: ${{ vars.GERRIT_SSH_USER }}
174 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
175 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
176 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
177 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
178 vote-type: ${{ env.WORKFLOW_CONCLUSION }}