Skip to content

Commit

Permalink
alignment and maintenance (#77)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
ksatirli authored Mar 15, 2023
1 parent d345de2 commit 367b335
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .copywrite.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
schema_version = 1

project {
header_ignore = [
"dist/index.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name: "GitHub Action: Self-Test"
on:
push:

env:
PRODUCT_VERSION: "1.8.6"

jobs:
setup-packer:
runs-on: ubuntu-latest
name: Test `setup-packer`
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -15,19 +18,19 @@ jobs:
uses: "./"
id: setup
with:
version: "1.8.6"
version: ${{ env.PRODUCT_VERSION }}

- name: Print `$PATH` for `packer`
run: which packer

- name: Print `packer` version
run: packer version

- name: Validate `packer` version is latest (`1.8.6``)
run: "if packer version | grep -q 'Packer v1.8.6'; then exit 0; else exit 1; fi;"
- name: Validate `packer` version is accurate
run: "packer version | grep --silent 'Packer v${{ env.PRODUCT_VERSION }}'"

- name: Run `packer fmt`
run: packer fmt "${{ github.action_path }}./test/hello-world.pkr.hcl"
run: packer fmt -check "./test/hello-world.pkr.hcl"

- name: Setup `packer` with an invalid version (using local GitHub Action)
uses: "./"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0

- name: Lint Code with Super-Linter
uses: github/super-linter@v4
uses: github/super-linter/slim@v4
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: "main"
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

<!-- TOC -->
Expand Down Expand Up @@ -32,7 +34,10 @@ Other [environment variables](https://developer.hashicorp.com/packer/docs/comman
name: packer

on:
- push
push:

env:
PRODUCT_VERSION: "1.8.6" # or: "latest"

jobs:
packer:
Expand All @@ -46,7 +51,7 @@ jobs:
uses: hashicorp/setup-packer@main
id: setup
with:
version: "1.8.6" # or `latest`
version: ${{ env.PRODUCT_VERSION }}

- name: Run `packer init`
id: init
Expand Down Expand Up @@ -89,8 +94,10 @@ We recommend storing these in [GitHub Actions Secrets](https://docs.github.com/e

```yaml
name: hcp-packer
on:
- push
jobs:
hcp-packer:
runs-on: ubuntu-latest
Expand All @@ -115,7 +122,7 @@ jobs:
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 }}
HCP_PACKER_BUILD_FINGERPRINT: "run.id.${{ github.run_id }}.run.attempt.${{ github.run_attempt }}"
```
## Author Information
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/hcp-packer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0

name: hcp-packer
on:
- push
Expand Down
3 changes: 3 additions & 0 deletions examples/packer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-2.0

name: packer

on:
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-packer",
"version": "2.0.0",
"version": "2.1.0",
"description": "A GitHub Action to install a specific version of HashiCorp Packer and add it to PATH.",
"keywords": [
"github-actions",
Expand All @@ -22,7 +22,7 @@
"@actions/core": "1.10.0",
"@actions/io": "1.1.2",
"@actions/tool-cache": "2.0.1",
"@hashicorp/github-actions-core": "github:hashicorp/github-actions-core#v0.2.0",
"@hashicorp/github-actions-core": "github:hashicorp/github-actions-core#v0.3.0",
"@vercel/ncc": "0.36.1"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import * as core from "@actions/core";
import * as hc from "@hashicorp/github-actions-core";

async function main() {
const version = core.getInput("version")
const version = core.getInput("version");
if (version == null) {
core.setFailed("Required field 'version' not set")
return
core.setFailed("Required field 'version' not set");
return;
}
try {
await hc.getHashicorpRelease("packer", version);
Expand Down
8 changes: 4 additions & 4 deletions test/hello-world.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# file: builds.pkr.hcl
source "file" "basic-example" {
content = "Lorem ipsum dolor sit amet"
target = "sample_artifact"
target = "sample_artifact"
}

variable "bucket_name" {
type = string
type = string
default = "hello-world"
}

build {
hcp_packer_registry {
hcp_packer_registry {
bucket_name = "${var.bucket_name}"

description = <<EOT
Expand All @@ -22,7 +22,7 @@ Some nice description about the image which artifact is being published to HCP P

labels = {
"foo-version" = "3.4.0",
"foo" = "bar",
"foo" = "bar",
}
}

Expand Down

0 comments on commit 367b335

Please sign in to comment.