/setup-nomad-pack

GitHub Action for HashiCorp Nomad Pack

Primary LanguageSmartyApache License 2.0Apache-2.0

GitHub Action: setup-nomad-pack

The hashicorp/setup-nomad-pack Action sets up the Nomad Pack CLI in your GitHub Actions workflow by adding the nomad-pack binary to PATH.

GitHub Action: Self-Test

Table of Contents

Requirements

This GitHub Actions supports all commands that are available in the nomad-pack CLI.

The run, destroy, info, and status commands require access to a Nomad cluster, as defined through the environment variable NOMAD_ADDR.

Other environment variables (such as NOMAD_TOKEN) may be set as normal and will be picked up accordingly.

Usage

1.) Create GitHub Actions Secrets by going to the repository's Settings tab, followed by expanding the Secrets sidebar, and finally Actions.

  • Set the NOMAD_ADDR to the IP-address or hostname of a Nomad cluster that is routable for GitHub Actions Runners.
  • Set the NOMAD_TOKEN to a token with appropriate permissions to carry out Pack-specific operations on a Nomad cluster.

Optionally, set any and all environment variables as required for your Nomad cluster.

Warning Running services such as Nomad on a publicly accessible port without authentication may be harmful.

Consult with your security team to define an access policy that meets your organization's security demands.

GitHub Actions run on a publicly-known list of IP addresses. This data may be retrieved through HashiCorp Terraform, using the ip_ranges data source, allowing you to make IP-address one of the security considerations.

2.) Create a GitHub Actions Workflow file (e.g.: .github/workflows/nomad-pack.yml):

name: nomad-pack

on:
  push:

env:
  PRODUCT_VERSION: "0.1.1"

jobs:
  setup-nomad-pack:
    runs-on: ubuntu-latest
    name: Run Nomad Pack
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup `nomad-pack`
        uses: hashicorp/setup-nomad-pack@main
        id: setup
        with:
          version: ${{ env.PRODUCT_VERSION }}

      - name: Run `nomad-pack info` for `./test`
        id: info
        run: "nomad-pack render ./test"

      - name: Run `nomad-pack run` for `./test`
        id: run
        run: "nomad-pack run ./test"
        env:
          NOMAD_ADDR: "${{ secrets.NOMAD_ADDR }}"
          NOMAD_TOKEN: "${{ secrets.NOMAD_TOKEN }}"
        continue-on-error: true

      - name: Run `nomad-pack version`
        id: version
        run: "nomad-pack version"

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.
  • The origin of this GitHub Action has been set as hashicorp/setup-nomad-pack@main. For newer versions, see the Releases.
  • The version of nomad-pack to set up has been set as 0.1.1. For a complete list, see releases.hashicorp.com.
  • The pack to interact with has been set to ./test

These definitions may require updating to suit your deployment, such as specifying self-hosted runners.

Additionally, you may configure outputs 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 - (required) The version of nomad-pack to install. Supports semver versioning. Defaults to latest.

Outputs

This section contains a list of all outputs that can be consumed from this Action.

  • version - The version of nomad-pack that was installed.

Author Information

This GitHub Action is maintained by the contributors listed on GitHub.

License

Licensed under the Apache License, Version 2.0 (the "License").

You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.

See the License for the specific language governing permissions and limitations under the License.