* set product version as variable
* use slim version of linter
* use check mode for self-test
* adds copywrite bot config and headers
* bumps `github-actions-core` from `0.2.0` to `0.3.0`
* bumps version to `2.1.0`
* linting
* docs linting
* bumps package versions to latest known working versions
* update self-test and makes it branch aware
* use existing version for base test
* linting
The `hashicorp/setup-packer` Action sets up the `packer` CLI in your GitHub Actions workflow by adding the binary to `PATH`.
The `hashicorp/setup-packer` Action sets up the [Packer](https://www.packer.io) CLI in your GitHub Actions workflow by adding the`packer` binary to `PATH`.
* [Integrating with HCP Packer](#integrating-with-hcp-packer)
* [Author Information](#author-information)
* [License](#license)
<!-- TOC -->
## Requirements
This GitHub Actions supports all commands that are available in the `packer` CLI.
The [`build`](https://www.packer.io/docs/commands/build) command may require access to provider-specific credentials.
The [`build`](https://developer.hashicorp.com/packer/docs/commands/build) command may require access to provider-specific credentials.
Other [environment variables](https://www.packer.io/docs/commands#environment-variables) (such as `PACKER_LOG`) may be set as normal and will be picked up accordingly.
Other [environment variables](https://developer.hashicorp.com/packer/docs/commands#environment-variables) (such as `PACKER_LOG`) may be set as normal and will be picked up accordingly.
## Usage
1.) Create a GitHub Actions Workflow file (e.g.: `.github/workflows/packer.yml`):
Create a GitHub Actions Workflow file (e.g.: `.github/workflows/packer.yml`):
```yaml
name:packer
on:
- push
push:
env:
PRODUCT_VERSION:"1.10.0"# or: "latest"
jobs:
packer:
@@ -35,13 +45,13 @@ jobs:
name:Run Packer
steps:
- name:Checkout
uses:actions/checkout@v3
uses:actions/checkout@v4
- name:Setup `packer`
uses:hashicorp/setup-packer@main
id:setup
with:
version:"1.8.3"# or `latest`
version:${{ env.PRODUCT_VERSION }}
- name:Run `packer init`
id:init
@@ -56,8 +66,8 @@ In the above example, the following definitions have been set.
- The event trigger has been set to `push`. For a complete list, see [Events that trigger workflows](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows).
- The origin of this GitHub Action has been set as `hashicorp/setup-packer@main`. For newer versions, see the [Releases](https://github.com/hashicorp/setup-packer/releases).
- The version of `packer` to set up has been set as `1.8.3`. For a complete list, see [releases.hashicorp.com](https://releases.hashicorp.com/packer/).
- The Packer manifest to interact with has been set as `./image.pkr.hcl`
- The version of `packer` to set up has been set as `1.10.0`. For a complete list, see [releases.hashicorp.com](https://releases.hashicorp.com/packer/).
- The Packer manifest to interact with has been set as `./image.pkr.hcl`.
These definitions may require updating to suit your deployment, such as specifying [self-hosted](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-self-hosted-runners) runners.
@@ -67,7 +77,10 @@ Additionally, you may configure [outputs](https://docs.github.com/en/actions/usi
This section contains a list of all inputs that may be set for this Action.
-`version` - (required) The version of `packer` to install. Defaults to `latest`.
-`version` - The version of `packer` to install. Defaults to `latest` if unset.
> [!NOTE]
> To retrieve the `latest` version, this GitHub Action polls the HashiCorp [Releases API](https://api.releases.hashicorp.com/v1/releases/packer) and finds the latest released version of Packer that isn't marked as a pre-release (`is_prerelease`).
## Outputs
@@ -75,6 +88,52 @@ This section contains a list of all outputs that can be consumed from this Actio
-`version` - The version of `packer` that was installed.
## Integrating with HCP Packer
To integrate with HCP Packer, add your HCP Client ID and HCP Client secret as environment variables to the Packer build call.
We add an `HCP_PACKER_BUILD_FINGERPRINT` in this example that is based on the workflow run ID, that way it is always unique
We recommend storing these in [GitHub Actions Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) (as opposed to plain-text).
For more information on using HCP Packer, see the [Getting Started tutorial](https://developer.hashicorp.com/packer/tutorials/hcp-get-started/hcp-push-image-metadata).
# see https://github.com/hashicorp/packer-plugin-hashicups/releases/tag/v1.0.2
hashicups={
version=">= 1.0.0"
source="github.com/hashicorp/hashicups"
}
}
}
# file: builds.pkr.hcl
source"file""basic-example"{
source"file""basic_example"{
content="Lorem ipsum dolor sit amet"
target="sample_artifact"
target="sample_artifact"
}
variable"bucket_name"{
type=string
type=string
default="hello-world"
}
build{
hcp_packer_registry{
hcp_packer_registry{
bucket_name="${var.bucket_name}"
description=<<EOT
Some nice description about the image which artifact is being published to HCP Packer Registry. =D
EOT
labels={
"foo-version"="3.4.0",
"foo"="bar",
bucket_labels={
"version"="1.2.3",
"foo"="bar",
}
}
sources=["sources.file.basic-example"]
sources=[
"sources.file.basic_example"
]
}
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.