Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
anchor

GitHub Action

Packer AMI Builder

v0.3

Packer AMI Builder

anchor

Packer AMI Builder

Use GitHub Action to execute Packer AMI build

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Packer AMI Builder

uses: zmingxie/[email protected]

Learn more about this action in zmingxie/packer-ami-builder

Choose a version

Packer AMI Builder

Use GitHub Action to execute Packer build commands. This supports both HCL and JSON packer template files.

For HCL Mode, set packerArgs to build . to load all .pkr.hcl files within the dir. To use the override variable file, set packerArgs to build -var-file=overrides.pkrvars.hcl

Input Parameters

Name Description Mandatory Default
packerArgs Arguments that will be passed down to the packer command Yes
workDir Working directory inside the container No .

Example

Create a workflow file (e.g .github/workflows/ami-build.yaml) like below:

name: Build an AMI using Packer

on:
  push:
    branches:
      - 'master'
jobs:
  packer-ami-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Packer AMI Build
        uses: zmingxie/packer-ami-builder@master
        with:
          packerArgs: 'build template.json'
          workDir: '.'
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: us-east-1