🎈 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.
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 |
There are two different ways to provide secrets to Packer: using environment variables or with a secret file.
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 }}
ℹ️ 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.
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.