Compare commits

...

32 Commits

Author SHA1 Message Date
Jenna Goldstrich
d38faf1295 Use GHA Core 0.4.1 (#92) 2024-02-09 07:44:12 -08:00
Akhan Zhakiyanov
6669b85272 feat: update action runner to use NodeJS 20 (#90)
* feat: update action to use NodeJS 20

* fix: bump major version as recommended by github

* fix: revert package version
2024-02-07 15:58:20 -08:00
hashicorp-copywrite[bot]
dabe112c5d [COMPLIANCE] Add Copyright and License Headers (#79)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-11-15 09:56:36 -08:00
Jenna Goldstrich
ecc5516821 Update Github-Actions-Core, Semver, remove Snyk (#87)
* Update Github-Actions-Core to mitigate semver CVE

* Bump io/tool cache to the same version used in core

* Remove Snyk
2023-11-15 09:41:06 -08:00
hashicorp-tsccr[bot]
fb333f6658 Result of tsccr-helper -log-level=info -pin-all-workflows . (#84)
Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
2023-09-13 17:02:32 +02:00
Jenna Goldstrich
35eb25af04 Update README.md (#83) 2023-08-17 10:06:37 -07:00
Kerim Satirli
367b335854 alignment and maintenance (#77)
* 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`
2023-03-15 10:41:30 +01:00
Jenna Goldstrich
d345de254e Add YAML encoding to HCP Packer example 2023-03-07 15:10:01 -08:00
Jenna Goldstrich
e7171338be Update readme with consistent file definition for packer templates 2023-03-07 15:09:24 -08:00
Jenna Goldstrich
18fbd16177 Add examples for HCP Packer (#76)
* Add examples for HCP Packer

* Update README.md

Co-authored-by: Kerim Satirli <ksatirli@users.noreply.github.com>

* Update README.md

Co-authored-by: Kerim Satirli <ksatirli@users.noreply.github.com>

* job name should be hcp packer

* Add Kerim's suggested synk changes

* add run id

* Update README.md

Co-authored-by: Alan Szlosek Jr <alan.szlosek@gmail.com>

* Update examples/hcp-packer.yml

Co-authored-by: Alan Szlosek Jr <alan.szlosek@gmail.com>

* Update README.md

Co-authored-by: Alan Szlosek Jr <alan.szlosek@gmail.com>

* fix fingerprint

---------

Co-authored-by: Kerim Satirli <ksatirli@users.noreply.github.com>
Co-authored-by: Alan Szlosek Jr <alan.szlosek@gmail.com>
2023-03-07 15:07:46 -08:00
Kerim Satirli
d5c2c40d11 Maintenance (#74)
* 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
2023-03-07 10:33:00 -08:00
hashicorp-copywrite[bot]
c666f87d3e [COMPLIANCE] Add Copyright and License Headers (#73)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-02-02 10:26:05 +01:00
Jenna Goldstrich
86de60ecdd Update README.md 2022-12-08 16:29:42 -08:00
Jenna Goldstrich
ae6b3ed3be Install Packer as a binary in user's path instead of being an interface for users to run Packer commands (#63)
* updates Actions config

* updates docs

* Remove unused code that was moved to the core library, update to hashicorp version of GHA-Core, which is currently still private

Co-authored-by: Kerim Satirli <k.satirli@gmail.com>
Co-authored-by: Alexey Kulakov <uni_que@me.com>
2022-12-08 22:46:34 +01:00
hashicorp-copywrite[bot]
8c999b2ff7 [COMPLIANCE] Update Apache-2.0 LICENSE (#66)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2022-12-07 13:05:00 -08:00
Warren Krewenki
39e578e79f Update dockerfile to use packer 1.8.4 (#62)
Update the base Dockerfile to pull in the latest packer:light instead of the old version currently used by this action.
2022-12-06 19:34:32 +01:00
Guillaume Winter
da1fc3d139 Update to packer 1.8.2 (#46)
* Update to packer 1.8.2

* Update to packer 1.8.2
2022-08-18 11:59:40 +02:00
Amar Lojo
85839311bf adds docs for HCP support (#40) 2022-04-13 14:24:30 +02:00
Alan Ning
591a97b495 Added doc to describe the working_directory field (#39) 2022-04-13 13:51:18 +02:00
William
ca6f8f3f18 Add working_directory to documentation (#26) 2022-04-13 13:48:49 +02:00
Amar Lojo
501495b3a3 HCP Client ID & Secret updated (#34)
changed syntax
2022-04-06 09:53:53 +02:00
Kuldeep Rishi
4a58ae79e4 Update to Packer 1.7.8 (#29) 2021-12-13 15:36:10 +01:00
Sylvia Moss
93da82af22 update changelog (#18) 2021-03-02 09:58:19 +01:00
Sylvia Moss
f3ef35b95e Document detailed logs and upgrade image to Packer v1.7.0 (#17)
* add docs for detailed logs

* update packer image to v1.7.0

* fix table format

* fix table and make target not required

* document target as directory

* make default target the working dir

* fix readme

* add init command to the list

* removes extraneous spaces

Co-authored-by: Kerim Satirli <k.satirli@gmail.com>
2021-02-27 06:38:18 -05:00
Kerim Satirli
552c468107 documentation updates (#15)
* updates links and documentation for new GH Org
2021-02-25 16:37:27 +01:00
Kerim Satirli
5338887b31 updates to Packer 1.6.6 (#13)
* updates to Packer 1.6.6
2021-01-22 19:08:56 +01:00
Tom Parker-Shemilt
74ff345c9a Add support for working_directory (#11) 2021-01-22 19:07:02 +01:00
Jason
9cd0219a3b update Dockerfile and Readme to packer 6.2 (#8)
* update Dockerfile and Readme to packer 1.6.2

* update README to pass quality check
2021-01-22 18:09:04 +01:00
Frank J. Lamantia
71e9f608bf Updates to fail if templates do not pass validation (#4) 2020-06-18 09:56:00 +02:00
Aaron Tesch
ebc43821c4 ISSUE 6 - Fixed usage section in README.md (#7)
Co-authored-by: Aaron Tesch <darc_wing@hotmail.com>
2020-06-18 09:55:39 +02:00
FrankTheTank
b4a8c1ee67 update uses line (#3) 2020-03-30 12:12:23 +02:00
Kerim Satirli
5236a2b53a updates Packer to 1.5.5 (#2)
* updates Packer to `1.5.5`
2020-03-27 11:31:18 +01:00
23 changed files with 52803 additions and 243 deletions

10
.copywrite.hcl Normal file
View File

@@ -0,0 +1,10 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0
schema_version = 1
project {
header_ignore = [
"dist/index.js"
]
}

51
.github/workflows/actions-self-test.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: "GitHub Action: Self-Test"
on:
push:
env:
PRODUCT_VERSION: "1.8.6"
jobs:
setup-packer:
name: Test `setup-packer`
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup `packer` (using local GitHub Action)
uses: "./"
id: setup
with:
version: ${{ env.PRODUCT_VERSION }}
- name: Print `$PATH` for `packer`
run: which packer
- name: Print `packer` version
run: packer version
- name: Validate `packer` version is accurate
run: "packer version | grep --silent 'Packer v${{ env.PRODUCT_VERSION }}'"
- name: Run `packer fmt`
run: packer fmt -check "./test/hello-world.pkr.hcl"
- name: Setup `packer` with an invalid version (using local GitHub Action)
uses: "./"
id: invalid_version
with:
version: "invalid_version"
continue-on-error: true
- name: Validate invalid version failed
if: steps.invalid_version.outcome == 'success'
run: echo "Installing an invalid version expected to fail but did not" && exit 1
- name: Setup `packer` with `latest` version (using local GitHub Action)
uses: "./"
id: latest_version
- name: Print `packer` version
run: packer version

View File

@@ -1,88 +0,0 @@
---
name: Code Quality
on:
pull_request:
env:
PARENT_ORG: operatehappy
META_PATH: dotfiles-org
SELF_PATH: repository
PYTHON_VERSION: 3.8
PYTHON_ARCH: x64
PRECOMMIT_CACHE_PATH: ".cache/pre-commit"
PRECOMMIT_VERSION: 1.18.3
PRECOMMIT_CONFIG: ".pre-commit-config.yaml"
jobs:
pre-commit:
runs-on: ubuntu-latest
name: pre-commit
steps:
- name: Checkout Meta Repository
uses: actions/checkout@v2
with:
repository: ${{ env.PARENT_ORG }}/${{ env.META_PATH }}
ref: master
path: ${{ env.META_PATH }}
fetch-depth: 1
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 1
path: ${{ env.SELF_PATH }}
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ env.PYTHON_ARCH }}
- name: Update and Restore pip Binaries Cache
uses: actions/cache@v1
id: cache-pip-binaries
with:
path: "${{ env.pythonLocation }}/bin"
key: "pip-binaries-${{ env.PYTHON_VERSION }}-${{ env.PRECOMMIT_VERSION }}"
- name: Update and Restore pip Packages Cache
uses: actions/cache@v1
id: cache-pip-packages
with:
path: "${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages"
key: "pip-packages-${{ env.PYTHON_VERSION }}-${{ env.PRECOMMIT_VERSION }}"
- name: Update and Restore pre-commit Cache
uses: actions/cache@v1
id: cache-precommit-hooks
with:
path: "~/${{ env.PRECOMMIT_CACHE_PATH }}"
key: ${{ hashFiles(format('{0}/{1}/{2}', github.workspace, env.META_PATH, env.PRECOMMIT_CONFIG )) }}
- name: Install `pre-commit` via `pip`
run: |
pip \
install "pre-commit==${{ env.PRECOMMIT_VERSION }}"
shell: sh
if: steps.cache-pip-binaries.outputs.cache-hit != 'true' && steps.cache-pip-packages.outputs.cache-hit != 'true'
- name: Setup `pre-commit`
run: |
pre-commit \
install \
--config "${{ github.workspace }}${{ env.UPSTREAM_REP }}/${{ env.PRECOMMIT_CONFIG }}"
shell: sh
working-directory: "${{ github.workspace }}/${{ env.SELF_PATH }}"
if: steps.cache-precommit.outputs.cache-hit != 'true'
- name: Run `pre-commit`
run: |
pre-commit \
run \
--config "${{ github.workspace }}/${{ env.META_PATH }}/${{ env.PRECOMMIT_CONFIG }}" \
--all-files
working-directory: "${{ github.workspace }}/${{ env.SELF_PATH }}"
shell: sh

View File

@@ -1,18 +0,0 @@
---
name: Repository Management
on:
pull_request:
jobs:
assign-pr-to-author:
runs-on: ubuntu-latest
name: assign-pr-to-author
steps:
- name: Assign Pull Request to Author
uses: technote-space/assign-author@v1
if: github.event_name == 'pull_request' && github.event.action == 'opened'
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

26
.github/workflows/superlinter.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
---
name: "Code Quality: Super-Linter"
on:
push:
jobs:
superlinter:
name: Super-Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code with Super-Linter
uses: github/super-linter/slim@45fc0d88288beee4701c62761281edfee85655d7 # v5.0.0
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: "main"
DISABLE_ERRORS: false
JAVASCRIPT_DEFAULT_STYLE: "prettier"
VALIDATE_JSON: true
VALIDATE_MD: true

35
.github/workflows/typescript.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
---
name: "Code Quality: TypeScript"
on:
push:
jobs:
nodejs:
name: Node.js
runs-on: ubuntu-latest
strategy:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false
matrix:
node-version:
- 20.x
steps:
- name: Checkout Repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 1
- name: Set up Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install NPM Packages
run: npm ci
- name: Build TypeScript code
run: npm run build

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# TODO: generate dist folder in CI
# dist/
node_modules/

11
.prettierrc.json Normal file
View File

@@ -0,0 +1,11 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"parser": "typescript",
"printWidth": 80,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}

View File

@@ -1,4 +1,11 @@
# `0.2.0` (2020-03-25)
# `0.3.0` (UNRELEASED, 2022-08)
* Update Dockerfile to point to packer version `1.8.2`
* Change `target` default to `.` [#17](https://github.com/hashicorp/packer-github-actions/pull/17)
* Mark `target` as not required [#17](https://github.com/hashicorp/packer-github-actions/pull/17)
* Add support for working_directory [#11](https://github.com/operatehappy/packer-github-actions/pull/11)
## `0.2.0` (2020-03-25)
* Adds Packer action (#1) ([d80192d](https://github.com/ksatirli/packer-github-actions/commit/d80192d)), closes [#1](https://github.com/ksatirli/packer-github-actions/issues/1)
* adds GitHub Actions for `code-quality` and `repository-management` ([2a0399e](https://github.com/ksatirli/packer-github-actions/commit/2a0399e))
@@ -6,4 +13,3 @@
## `0.1.0` (2020-03-24)
* adds base files ([6f7428a](https://github.com/ksatirli/packer-github-actions/commit/6f7428a))

View File

@@ -1,5 +0,0 @@
FROM hashicorp/packer:light@sha256:df7feeff930b04a42f2027dd0924392246f7b5a38f0c56531a2d14cd0d1e9408
COPY "entrypoint.sh" "/entrypoint.sh"
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -1,3 +1,5 @@
Copyright (c) 2020 HashiCorp, Inc.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

185
README.md
View File

@@ -1,112 +1,135 @@
# GitHub Action: Packer
# GitHub Action: `setup-packer`
> GitHub Action for running Packer [commands](https://packer.io/docs/commands/index.html).
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`.
[![GitHub Action: Self-Test](https://github.com/hashicorp/setup-packer/actions/workflows/actions-self-test.yml/badge.svg?branch=main)](https://github.com/hashicorp/setup-packer/actions/workflows/actions-self-test.yml)
## Table of Contents
- [GitHub Action: Packer](#github-action-packer)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Inputs](#inputs)
- [command](#command)
- [arguments](#arguments)
- [target](#target)
- [Notes](#notes)
- [Author Information](#author-information)
- [License](#license)
<!-- TOC -->
* [GitHub Action: `setup-packer`](#github-action--setup-packer)
* [Table of Contents](#table-of-contents)
* [Requirements](#requirements)
* [Usage](#usage)
* [Inputs](#inputs)
* [Outputs](#outputs)
* [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://developer.hashicorp.com/packer/docs/commands/build) command may require access to provider-specific credentials.
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
Add the Action to your [GitHub Workflow](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#creating-a-workflow-file) like so:
1.) Create a GitHub Actions Workflow file (e.g.: `.github/workflows/packer.yml`):
```yaml
---
name: Packer
name: packer
on:
push:
env:
PRODUCT_VERSION: "1.8.6" # or: "latest"
jobs:
packer:
runs-on: ubuntu-latest
name: packer
name: Run Packer
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
# fix backwards incompatibilities in template
- name: Fix Template
uses: operatehappy/packer-github-action
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
command: fix
version: ${{ env.PRODUCT_VERSION }}
# validate templates
- name: Validate Template
uses: operatehappy/packer-github-action
- name: Run `packer init`
id: init
run: "packer init ./image.pkr.hcl"
- name: Run `packer validate`
id: validate
run: "packer validate ./image.pkr.hcl"
```
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.6`. 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.
Additionally, you may configure [outputs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-defining-outputs-for-a-job) to consume return values from the Action's operations.
## Inputs
This section contains a list of all inputs that may be set for this Action.
- `version` - The version of `packer` to install. Defaults to `latest` if unset.
## Outputs
This section contains a list of all outputs that can be consumed from this Action.
- `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). See the [HCP Packer Getting Started tutorial](https://developer.hashicorp.com/packer/tutorials/hcp-get-started/hcp-push-image-metadata)
```yaml
name: hcp-packer
on:
- push
jobs:
hcp-packer:
runs-on: ubuntu-latest
name: Run Packer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
command: validate
arguments: -syntax-only
target: artifacts.pkr.json packer.json
version: "latest"
- name: Run `packer init`
id: init
run: "packer init ./image.pkr.hcl"
- name: Run `packer validate`
id: validate
run: "packer validate ./image.pkr.hcl"
# build artifact
- name: Build Artifact
uses: operatehappy/packer-github-action
with:
command: build
arguments: "-color=false -on-error=abort"
# additional steps to process artifacts
run: packer build -color=false -on-error=abort ./image.pkr.hcl
env:
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_PACKER_BUILD_FINGERPRINT: "run.id.${{ github.run_id }}.run.attempt.${{ github.run_attempt }}"
```
### Inputs
| Name | Description | Required | Default |
|-------------|-----------------------|----------|----------------------|
| `command` | command to execute | yes | |
| `arguments` | arguments for command | no | |
| `target` | file(s) to target | yes | `artifacts.pkr.json` |
#### `command`
`command` supports the following subset of Packer [CLI commands](https://packer.io/docs/commands/index.html):
- [build](https://packer.io/docs/commands/build.html) to generate a set of artifacts from a template
- [fix](https://packer.io/docs/commands/fix.html) to find and correct backwards incompatible stanzas in a template
- [validate](https://packer.io/docs/commands/validate.html) to validate the syntax and configuration of a template
Other CLI commands (`console`, `inspect` and `version`) are _technically_ supported, but have limited utility in a GitHub Actions Workflow, due to their interactive nature.
#### `arguments`
`arguments` supports all options available for the respective `command`.
The arguments must be provided as a single string. Multiple arguments should be concatenated like so: "-color=false -on-error=abort"
#### `target`
`target` supports a string consisting of one or more file paths:
```yaml
# single file
target: artifacts.pkr.json
# multiple files, separated by whitespace
target: artifacts.pkr.json packer.json
```
The Action will iterate over each file and run each `command`, separately.
## Notes
- To enable debug logging, create a secret named `ACTIONS_STEP_DEBUG` with the value `true`. See [here](https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-debug-message) for more information.
## Author Information
This module is maintained by the contributors listed on [GitHub](https://github.com/operatehappy/packer-github-action/graphs/contributors).
This GitHub Action is maintained by the contributors listed on [GitHub](https://github.com/hashicorp/setup-packer/graphs/contributors).
Development of this module was sponsored by [Operate Happy](https://github.com/operatehappy).
The original code of this repository is based on work done by [Matthew Sanabria](https://github.com/sudomateo) as part of the [setup-packer](https://github.com/sudomateo/setup-packer) GitHub Action.
## License

View File

@@ -1,28 +1,22 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0
---
name: Packer GitHub Actions
author: Kerim Satirli <kerim@operatehappy.com>
description: Run Packer commands
name: "Setup HashiCorp Packer"
author: "Kerim Satirli"
description: "A GitHub Action to install a specific version of HashiCorp Packer and add it to PATH."
inputs:
command:
description: command to execute
version:
description: "The Packer version to install and add to PATH."
required: true
arguments:
description: arguments for command
target:
description: file(s) to target
required: true
default: artifacts.pkr.json
default: "latest"
outputs:
command:
description: interpolated command (incl. arguments) that will be executed
version:
description: "The Packer version that was installed and added to PATH."
runs:
using: 'docker'
image: 'Dockerfile'
using: "node20"
main: "dist/index.js"
branding:
color: blue
icon: package
icon: "package"
color: "blue"

51920
dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,oDAAsC;AACtC,mEAAqD;AAErD,SAAe,IAAI;;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,IAAI,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;YACnD,OAAO;SACR;QACD,IAAI;YACF,MAAM,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;SACjD;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,KAAK,YAAY,KAAK,EAAE;gBAC1B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aAC/B;SACF;IACH,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env bash
# fail if INPUT_COMMAND is not set
if [ -z "${INPUT_COMMAND}" ]; then
echo "Required variable \`command\` is missing"
exit 1
fi
# assemble operation
if [ -z "${INPUT_ARGUMENTS}" ]; then
OPERATION="packer ${INPUT_COMMAND}"
else
OPERATION="packer ${INPUT_COMMAND} ${INPUT_ARGUMENTS}"
fi
echo "::debug:: Executing command: ${OPERATION}"
# cast INPUT_TARGET string to "array"
# shellcheck disable=SC2206
TARGETS=(${INPUT_TARGET})
# iterate over target(s)
for TARGET in "${TARGETS[@]}"; do
echo "::debug:: Processing target ${TARGET}"
# shellcheck disable=SC2086
${OPERATION} "${TARGET}"
done

31
examples/hcp-packer.yml Normal file
View File

@@ -0,0 +1,31 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0
name: hcp-packer
on:
- push
jobs:
hcp-packer:
runs-on: ubuntu-latest
name: Run Packer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: "latest"
- name: Run `packer init`
id: init
run: "packer init ./image.pkr.hcl"
- name: Run `packer validate`
id: validate
run: "packer validate ./image.pkr.hcl"
- name: Build Artifact
run: packer build -color=false -on-error=abort image.pkr.hcl
env:
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_PACKER_BUILD_FINGERPRINT: run.id.${{ github.run_id }}.run.attempt.${{ github.run_attempt }}

29
examples/packer.yml Normal file
View File

@@ -0,0 +1,29 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0
name: packer
on:
- push
jobs:
packer:
runs-on: ubuntu-latest
name: Run Packer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: "1.8.6" # or latest
- name: Run `packer init`
id: init
run: "packer init ./image.pkr.hcl"
- name: Run `packer validate`
id: validate
run: "packer validate ./image.pkr.hcl"

453
package-lock.json generated Normal file
View File

@@ -0,0 +1,453 @@
{
"name": "setup-packer",
"version": "3.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "setup-packer",
"version": "3.0.0",
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "1.10.1",
"@actions/io": "1.1.3",
"@actions/tool-cache": "2.0.1",
"@hashicorp/github-actions-core": "github:hashicorp/github-actions-core#v0.4.1",
"@vercel/ncc": "0.36.1"
},
"devDependencies": {
"@types/node": "^20.11.10",
"@types/semver": "7.5.4",
"prettier": "2.8.4",
"typescript": "4.9.5"
}
},
"node_modules/@actions/core": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/http-client": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz",
"integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==",
"dependencies": {
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
},
"node_modules/@actions/io": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
},
"node_modules/@actions/tool-cache": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.1",
"semver": "^6.1.0",
"uuid": "^3.3.2"
}
},
"node_modules/@actions/tool-cache/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
"engines": {
"node": ">=14"
}
},
"node_modules/@hashicorp/github-actions-core": {
"version": "0.4.1",
"resolved": "git+ssh://git@github.com/hashicorp/github-actions-core.git#0f2bccbcefcf1876bb86a5f9efeb10f59dc4fb99",
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@hashicorp/js-releases": "^1.7.2",
"semver": "^7.5.3"
}
},
"node_modules/@hashicorp/github-actions-core/node_modules/semver": {
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@hashicorp/js-releases": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/@hashicorp/js-releases/-/js-releases-1.7.2.tgz",
"integrity": "sha512-YuvQl8OZIzsUAiUGT3ewXlTJkMzOBMybwr6Uiy4GdWNzjl0fLQAVIGDmCZbvEOxWhpK1OhElS5mZwAo+SbqoKw==",
"dependencies": {
"axios": "^1.6.2",
"https-proxy-agent": "^5.0.1",
"openpgp": "^5.5.0",
"semver": "^7.3.5",
"yauzl": "^2.10.0"
}
},
"node_modules/@hashicorp/js-releases/node_modules/semver": {
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@types/node": {
"version": "20.11.16",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz",
"integrity": "sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@types/semver": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==",
"dev": true
},
"node_modules/@vercel/ncc": {
"version": "0.36.1",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz",
"integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==",
"bin": {
"ncc": "dist/ncc/cli.js"
}
},
"node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"dependencies": {
"debug": "4"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/asn1.js": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
"integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==",
"dependencies": {
"bn.js": "^4.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"safer-buffer": "^2.1.0"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.6.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
"integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
"dependencies": {
"follow-redirects": "^1.15.4",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/bn.js": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="
},
"node_modules/buffer-crc32": {
"version": "0.2.13",
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
"engines": {
"node": "*"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/fd-slicer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==",
"dependencies": {
"pend": "~1.2.0"
}
},
"node_modules/follow-redirects": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/https-proxy-agent": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
"dependencies": {
"agent-base": "6",
"debug": "4"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/openpgp": {
"version": "5.11.0",
"resolved": "https://registry.npmjs.org/openpgp/-/openpgp-5.11.0.tgz",
"integrity": "sha512-hytHsxIPtRhuh6uAmoBUThHSwHSX3imLu7x4453T+xkVqIw49rl22MRD4KQIAQdCDoVdouejzYgcuLmMA/2OAA==",
"dependencies": {
"asn1.js": "^5.0.0"
},
"engines": {
"node": ">= 8.0.0"
}
},
"node_modules/pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg=="
},
"node_modules/prettier": {
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/typescript": {
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/undici": {
"version": "5.28.3",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.3.tgz",
"integrity": "sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": {
"node": ">=14.0"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"node_modules/yauzl": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
"dependencies": {
"buffer-crc32": "~0.2.3",
"fd-slicer": "~1.1.0"
}
}
}
}

34
package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "setup-packer",
"version": "3.0.0",
"description": "A GitHub Action to install a specific version of HashiCorp Packer and add it to PATH.",
"keywords": [
"github-actions",
"hashicorp",
"packer"
],
"repository": {
"type": "git",
"url": "git@github.com:hashicorp/setup-packer.git"
},
"license": "Apache-2.0",
"author": "Kerim Satirli <kerim@hashicorp.com> & Jenna Goldstrich <jgoldstrich@hashicorp.com>",
"main": "dist/index.js",
"scripts": {
"build": "tsc && ncc build --no-cache",
"fmt": "prettier --write 'src/*.ts'"
},
"dependencies": {
"@actions/core": "1.10.1",
"@actions/io": "1.1.3",
"@actions/tool-cache": "2.0.1",
"@hashicorp/github-actions-core": "github:hashicorp/github-actions-core#v0.4.1",
"@vercel/ncc": "0.36.1"
},
"devDependencies": {
"@types/node": "^20.11.10",
"@types/semver": "7.5.4",
"prettier": "2.8.4",
"typescript": "4.9.5"
}
}

24
src/index.ts Normal file
View File

@@ -0,0 +1,24 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import * as core from "@actions/core";
import * as hc from "@hashicorp/github-actions-core";
async function main() {
const version = core.getInput("version");
if (version == null) {
core.setFailed("Required field 'version' not set");
return;
}
try {
await hc.getHashicorpRelease("packer", version);
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
}
}
main();

31
test/hello-world.pkr.hcl Normal file
View File

@@ -0,0 +1,31 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0
# file: builds.pkr.hcl
source "file" "basic-example" {
content = "Lorem ipsum dolor sit amet"
target = "sample_artifact"
}
variable "bucket_name" {
type = string
default = "hello-world"
}
build {
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",
}
}
sources = ["sources.file.basic-example"]
}

15
tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"esModuleInterop": true,
"target": "es6",
"module": "commonjs",
"outDir": "./dist",
"pretty": true,
"removeComments": true,
"sourceMap": true,
"strict": true
},
"exclude": [
"node_modules"
]
}