Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f53647d4d | |||
| 5e16424917 | |||
| 8c999b2ff7 | |||
| 39e578e79f | |||
| da1fc3d139 | |||
| 85839311bf | |||
| 591a97b495 | |||
| ca6f8f3f18 | |||
| 501495b3a3 | |||
| 4a58ae79e4 | |||
| 93da82af22 | |||
| f3ef35b95e | |||
| 552c468107 | |||
| 5338887b31 | |||
| 74ff345c9a | |||
| 9cd0219a3b | |||
| 71e9f608bf | |||
| ebc43821c4 | |||
| b4a8c1ee67 | |||
| 5236a2b53a |
@@ -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
|
||||
@@ -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 }}
|
||||
+8
-2
@@ -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))
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
FROM hashicorp/packer:light@sha256:df7feeff930b04a42f2027dd0924392246f7b5a38f0c56531a2d14cd0d1e9408
|
||||
# see https://hub.docker.com/r/hashicorp/packer/tags for all available tags
|
||||
FROM hashicorp/packer:light@sha256:dd9868ae2b4d4fc658ed32ab9f3277b0a85ad266f8880351f2d51de038e4db5c
|
||||
|
||||
COPY "entrypoint.sh" "/entrypoint.sh"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Copyright (c) 2020 HashiCorp, Inc.
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# GitHub Action: Packer
|
||||
|
||||
> GitHub Action for running Packer [commands](https://packer.io/docs/commands/index.html).
|
||||
> GitHub Action for running Packer [commands](https://www.packer.io/docs/commands).
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -8,16 +8,18 @@
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Usage](#usage)
|
||||
- [Inputs](#inputs)
|
||||
- [command](#command)
|
||||
- [arguments](#arguments)
|
||||
- [target](#target)
|
||||
- [`command`](#command)
|
||||
- [`arguments`](#arguments)
|
||||
- [`target`](#target)
|
||||
- [`working_directory`](#working_directory)
|
||||
- [Detailed logs](#detailed-logs)
|
||||
- [Notes](#notes)
|
||||
- [Author Information](#author-information)
|
||||
- [License](#license)
|
||||
|
||||
## 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:
|
||||
Add the Action to your [GitHub Workflow](https://docs.github.com/en/actions/learn-github-actions#creating-a-workflow-file) like so:
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -38,43 +40,51 @@ jobs:
|
||||
|
||||
# fix backwards incompatibilities in template
|
||||
- name: Fix Template
|
||||
uses: operatehappy/packer-github-action
|
||||
uses: hashicorp/packer-github-actions@master
|
||||
with:
|
||||
command: fix
|
||||
|
||||
# validate templates
|
||||
- name: Validate Template
|
||||
uses: operatehappy/packer-github-action
|
||||
uses: hashicorp/packer-github-actions@master
|
||||
with:
|
||||
command: validate
|
||||
arguments: -syntax-only
|
||||
target: artifacts.pkr.json packer.json
|
||||
target: packer.pkr.hcl
|
||||
|
||||
# build artifact
|
||||
- name: Build Artifact
|
||||
uses: operatehappy/packer-github-action
|
||||
uses: hashicorp/packer-github-actions@master
|
||||
with:
|
||||
command: build
|
||||
arguments: "-color=false -on-error=abort"
|
||||
target: packer.pkr.hcl
|
||||
working_directory: infrastructure/packer
|
||||
env:
|
||||
PACKER_LOG: 1
|
||||
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
|
||||
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
|
||||
|
||||
# additional steps to process artifacts
|
||||
```
|
||||
|
||||
### Inputs
|
||||
|
||||
| Name | Description | Required | Default |
|
||||
|-------------|-----------------------|----------|----------------------|
|
||||
| `command` | command to execute | yes | |
|
||||
| `arguments` | arguments for command | no | |
|
||||
| `target` | file(s) to target | yes | `artifacts.pkr.json` |
|
||||
| Name | Description | Required | Default |
|
||||
|---------------------|--------------------------------|----------|---------|
|
||||
| `command` | command to execute | yes | |
|
||||
| `arguments` | arguments for command | no | |
|
||||
| `target` | file(s) or directory to target | no | `.` |
|
||||
| `working_directory` | working directory for command | no | `.` |
|
||||
|
||||
#### `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
|
||||
- [init](https://www.packer.io/docs/commands/init) to download Packer plugin binaries
|
||||
- [build](https://www.packer.io/docs/commands/build) to generate a set of artifacts from a template
|
||||
- [fix](https://www.packer.io/docs/commands/fix) to find and correct backwards incompatible stanzas in a template
|
||||
- [validate](https://www.packer.io/docs/commands/validate) 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.
|
||||
|
||||
@@ -82,29 +92,58 @@ Other CLI commands (`console`, `inspect` and `version`) are _technically_ suppor
|
||||
|
||||
`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"
|
||||
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:
|
||||
`target` supports a string consisting of one or more file or directory paths:
|
||||
|
||||
```yaml
|
||||
# single file
|
||||
target: artifacts.pkr.json
|
||||
target: artifacts.pkr.hcl
|
||||
|
||||
# multiple files, separated by whitespace
|
||||
target: artifacts.pkr.json packer.json
|
||||
target: artifacts.pkr.hcl packer.pkr.hcl
|
||||
|
||||
# working directory
|
||||
target: .
|
||||
```
|
||||
|
||||
The Action will iterate over each file and run each `command`, separately.
|
||||
|
||||
#### `working_directory`
|
||||
|
||||
`working_directory` supports a string consisting of a directory path. This should be a relative path in your repository where you want the packer command to run.
|
||||
|
||||
## Detailed logs
|
||||
|
||||
Packer has an option to enable more detailed logs by setting the `PACKER_LOG` environment variable.
|
||||
Any value other than `""` (empty string) and `"0"`, will cause detailed logs to appear on stderr.
|
||||
|
||||
To set `PACKER_LOG=1`, simply define the environment variable in the step configuration like:
|
||||
|
||||
```yaml
|
||||
# build artifact
|
||||
- name: Build Artifact
|
||||
uses: hashicorp/packer-github-actions@master
|
||||
with:
|
||||
command: build
|
||||
arguments: "-color=false -on-error=abort"
|
||||
target: packer.pkr.hcl
|
||||
env:
|
||||
PACKER_LOG: 1
|
||||
```
|
||||
|
||||
## 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.
|
||||
- To enable debug logging, create a secret named `ACTIONS_STEP_DEBUG` with the value `true`. See [here](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-debug-message) for more information.
|
||||
|
||||
- If you want to use HCP Packer as central image repository, do not forget to add HCP Secrets under your repo settings. See [here](https://github.com/Azure/actions-workflow-samples/blob/master/assets/create-secrets-for-GitHub-workflows.md)
|
||||
- When using [HCP Packer Registry](https://cloud.hashicorp.com/docs/packer), you will need to set `HCP_CLIENT_ID` and `HCP_CLIENT_SECRET` environment variables to your job steps. See [Service Principals](https://cloud.hashicorp.com/docs/hcp/access-control/service-principals) guide for how you can generate these credentials, and [Encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) guide for how you can configure and reference secrets in your Actions.
|
||||
|
||||
## Author Information
|
||||
|
||||
This module is maintained by the contributors listed on [GitHub](https://github.com/operatehappy/packer-github-action/graphs/contributors).
|
||||
This module is maintained by the contributors listed on [GitHub](https://github.com/hashicorp/packer-github-actions/graphs/contributors).
|
||||
|
||||
Development of this module was sponsored by [Operate Happy](https://github.com/operatehappy).
|
||||
|
||||
|
||||
+7
-3
@@ -10,10 +10,14 @@ inputs:
|
||||
required: true
|
||||
arguments:
|
||||
description: arguments for command
|
||||
required: false
|
||||
working_directory:
|
||||
description: working directory for command (defaults to root)
|
||||
required: false
|
||||
target:
|
||||
description: file(s) to target
|
||||
required: true
|
||||
default: artifacts.pkr.json
|
||||
description: file(s) or directory to target
|
||||
required: false
|
||||
default: .
|
||||
|
||||
outputs:
|
||||
command:
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# fail if INPUT_COMMAND is not set
|
||||
if [ -z "${INPUT_COMMAND}" ]; then
|
||||
echo "Required variable \`command\` is missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${INPUT_WORKING_DIRECTORY}" ]; then
|
||||
cd "${INPUT_WORKING_DIRECTORY}"
|
||||
fi
|
||||
|
||||
# assemble operation
|
||||
if [ -z "${INPUT_ARGUMENTS}" ]; then
|
||||
OPERATION="packer ${INPUT_COMMAND}"
|
||||
|
||||
Reference in New Issue
Block a user