mirror of
https://github.com/hashicorp/setup-packer.git
synced 2026-04-01 17:12:32 +00:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d38faf1295 | ||
|
|
6669b85272 | ||
|
|
dabe112c5d | ||
|
|
ecc5516821 | ||
|
|
fb333f6658 | ||
|
|
35eb25af04 | ||
|
|
367b335854 | ||
|
|
d345de254e | ||
|
|
e7171338be | ||
|
|
18fbd16177 | ||
|
|
d5c2c40d11 | ||
|
|
c666f87d3e | ||
|
|
86de60ecdd | ||
|
|
ae6b3ed3be | ||
|
|
8c999b2ff7 | ||
|
|
39e578e79f | ||
|
|
da1fc3d139 | ||
|
|
85839311bf | ||
|
|
591a97b495 | ||
|
|
ca6f8f3f18 | ||
|
|
501495b3a3 | ||
|
|
4a58ae79e4 | ||
|
|
93da82af22 | ||
|
|
f3ef35b95e | ||
|
|
552c468107 | ||
|
|
5338887b31 | ||
|
|
74ff345c9a | ||
|
|
9cd0219a3b | ||
|
|
71e9f608bf | ||
|
|
ebc43821c4 | ||
|
|
b4a8c1ee67 | ||
|
|
5236a2b53a |
10
.copywrite.hcl
Normal file
10
.copywrite.hcl
Normal 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
51
.github/workflows/actions-self-test.yml
vendored
Normal 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
|
||||
88
.github/workflows/code-quality.yml
vendored
88
.github/workflows/code-quality.yml
vendored
@@ -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
|
||||
18
.github/workflows/repository-management.yml
vendored
18
.github/workflows/repository-management.yml
vendored
@@ -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
26
.github/workflows/superlinter.yml
vendored
Normal 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
35
.github/workflows/typescript.yml
vendored
Normal 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
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# TODO: generate dist folder in CI
|
||||
# dist/
|
||||
node_modules/
|
||||
11
.prettierrc.json
Normal file
11
.prettierrc.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": false,
|
||||
"parser": "typescript",
|
||||
"printWidth": 80,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "es5",
|
||||
"useTabs": false
|
||||
}
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -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))
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM hashicorp/packer:light@sha256:df7feeff930b04a42f2027dd0924392246f7b5a38f0c56531a2d14cd0d1e9408
|
||||
|
||||
COPY "entrypoint.sh" "/entrypoint.sh"
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
2
LICENSE
2
LICENSE
@@ -1,3 +1,5 @@
|
||||
Copyright (c) 2020 HashiCorp, Inc.
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
185
README.md
185
README.md
@@ -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`.
|
||||
|
||||
[](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
|
||||
|
||||
|
||||
36
action.yml
36
action.yml
@@ -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
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
1
dist/index.js.map
vendored
Normal 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"}
|
||||
@@ -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
31
examples/hcp-packer.yml
Normal 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
29
examples/packer.yml
Normal 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
453
package-lock.json
generated
Normal 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
34
package.json
Normal 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
24
src/index.ts
Normal 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
31
test/hello-world.pkr.hcl
Normal 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
15
tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user