Skip to content

GitHub action to build virtual-machine images using Packer

Notifications You must be signed in to change notification settings

santisaez/packer-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Packer GitHub Action

🎈 Welcome to packer-action! 👋

packer-action is a GitHub action that builds virtual-machine images using Packer.

It's a Docker-based action that uses the official hashicorp/packer image from HashiCorp.

Inputs

Name Description Required Default
only Run only the specified Virtual-Machine builders no n/a
options Optional command arguments to be provided when calling Packer no n/a
secret The secret will be written to /tmp/packer-secret, see "Providing Secrets" no n/a
template Path to the config file of Packer yes default.json

Providing Secrets to Packer

There are two different ways to provide secrets to Packer: using environment variables or with a secret file.

Environment Variables

This is the preferred method, use it unless the builder requires reading secrets from a file.

The secrets are provided to Packer as environment variables using the encrypted secrets feature of GitHub Actions.

Example:

uses: santisaez/packer-action@v1
with:
  template: nginx-digitalocean.json
env:
  DIGITALOCEAN_API_TOKEN: ${{ secrets.DIGITALOCEAN_API_TOKEN }}

Secret File

ℹ️ Use this method only if the builder does not support reading secrets from environment variables, such as Google Cloud.

The content of the secret input parameter will be written to /tmp/packer-secret.

Example:

uses: santisaez/packer-action@v1
with:
  template: nginx-gcp.json
  secret: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
env:
  GOOGLE_APPLICATION_CREDENTIALS: '/tmp/packer-secret'

The googlecompute builder of Packer reads the Service Account credentials from a file whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable, and this variable points to the /tmp/packer-secret file generated by the GitHub action that contains the secret provided as input parameter.

Example Usage

This is a basic use case where a Packer template and an API token are provided to create an image in DigitalOcean:

uses: santisaez/packer-action@v1
with:
  template: nginx-digitalocean.json
env:
  DIGITALOCEAN_API_TOKEN: ${{ secrets.DIGITALOCEAN_API_TOKEN }}

See the /examples directory for more advanced workflow use cases.

About

GitHub action to build virtual-machine images using Packer

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published