Skip to content

Commit

Permalink
fix: packer validation and build CI pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
sydrawat01 committed Jan 9, 2024
1 parent 32263fa commit e70a4f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/packer-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ jobs:
- name: Packer variables
run: |
touch ami.pkrvars.hcl
touch aws/packer/ami.pkrvars.hcl
echo ami_prefix=\"${{ vars.AMI_PREFIX }}\" >> ami.pkrvars.hcl
echo OS=\"${{ vars.OS }}\" >> ami.pkrvars.hcl
echo ubuntu_version=\"${{ vars.VERSION }}\" >> ami.pkrvars.hcl
echo ssh_username=\"${{ secrets.SSH }}\" >> ami.pkrvars.hcl
echo subnet_id=\"${{ secrets.SUBNET_ID }}\" >> ami.pkrvars.hcl
echo dev_id=\"${{ secrets.DEV_ID }}\" >> ami.pkrvars.hcl
echo prod_id=\"${{ secrets.PROD_ID }}\" >> ami.pkrvars.hcl
echo source_ami=\"${{ var.SOURCE_AMI }}\" >> ami.pkrvars.hcl
echo aws_region=\"${{ var.AWS_REGION }}\" >> ami.pkrvars.hcl
echo instance_type=\"${{ var.INSTANCE_TYPE}}\" >> ami.pkrvars.hcl
echo volume_type=\"${{ var.VOLUME_TYPE}}\" >> ami.pkrvars.hcl
echo volume_size=\"${{ var.VOLUME_SIZE}}\" >> ami.pkrvars.hcl
echo device_name=\"${{ var.DEVICE_NAME}}\" >> ami.pkrvars.hcl
echo source_ami=\"${{ vars.SOURCE_AMI }}\" >> ami.pkrvars.hcl
echo aws_region=\"${{ vars.AWS_REGION }}\" >> ami.pkrvars.hcl
echo instance_type=\"${{ vars.INSTANCE_TYPE}}\" >> ami.pkrvars.hcl
echo volume_type=\"${{ vars.VOLUME_TYPE}}\" >> ami.pkrvars.hcl
echo volume_size=\"${{ vars.VOLUME_SIZE}}\" >> ami.pkrvars.hcl
echo device_name=\"${{ vars.DEVICE_NAME}}\" >> ami.pkrvars.hcl
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/packer-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Packer AMI template validation

on:
workflow_dispatch:
# pull_request:
# branches: [master]
pull_request:
branches: [master]

jobs:
validate:
Expand All @@ -21,20 +21,21 @@ jobs:
- name: Packer variables
run: |
touch ami.pkrvars.hcl
touch aws/packer/ami.pkrvars.hcl
echo ami_prefix=\"${{ vars.AMI_PREFIX }}\" >> ami.pkrvars.hcl
echo OS=\"${{ vars.OS }}\" >> ami.pkrvars.hcl
echo ubuntu_version=\"${{ vars.VERSION }}\" >> ami.pkrvars.hcl
echo ssh_username=\"${{ secrets.SSH }}\" >> ami.pkrvars.hcl
echo subnet_id=\"${{ secrets.SUBNET_ID }}\" >> ami.pkrvars.hcl
echo dev_id=\"${{ secrets.DEV_ID }}\" >> ami.pkrvars.hcl
echo prod_id=\"${{ secrets.PROD_ID }}\" >> ami.pkrvars.hcl
echo source_ami=\"${{ var.SOURCE_AMI }}\" >> ami.pkrvars.hcl
echo aws_region=\"${{ var.AWS_REGION }}\" >> ami.pkrvars.hcl
echo instance_type=\"${{ var.INSTANCE_TYPE}}\" >> ami.pkrvars.hcl
echo volume_type=\"${{ var.VOLUME_TYPE}}\" >> ami.pkrvars.hcl
echo volume_size=\"${{ var.VOLUME_SIZE}}\" >> ami.pkrvars.hcl
echo device_name=\"${{ var.DEVICE_NAME}}\" >> ami.pkrvars.hcl
echo source_ami=\"${{ vars.SOURCE_AMI }}\" >> ami.pkrvars.hcl
echo aws_region=\"${{ vars.AWS_REGION }}\" >> ami.pkrvars.hcl
echo instance_type=\"${{ vars.INSTANCE_TYPE}}\" >> ami.pkrvars.hcl
echo volume_type=\"${{ vars.VOLUME_TYPE}}\" >> ami.pkrvars.hcl
echo volume_size=\"${{ vars.VOLUME_SIZE}}\" >> ami.pkrvars.hcl
echo device_name=\"${{ vars.DEVICE_NAME}}\" >> ami.pkrvars.hcl
cp ami.pkrvars.hcl aws/packer
- name: Setup `packer`
uses: hashicorp/setup-packer@main
Expand All @@ -44,7 +45,7 @@ jobs:

- name: Packer init, format and validate template with datasources
run: |
cd aws/packer/
cd aws/packer &&
packer fmt .
packer init ami.pkr.hcl
packer validate -evaluate-datasources --var-file=ami.pkrvars.hcl ami.pkr.hcl
packer validate -syntax-only --var-file=ami.pkrvars.hcl ami.pkr.hcl

0 comments on commit e70a4f8

Please sign in to comment.