Small GitHub Action that makes requests to a Hashicorp Nomad server and collects logs from a given job.
Get logs from a service job
name: Get logs from Nomad Job
on: [push]
jobs:
logs:
name: Nomad Logs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Get logs from Nomad
uses: younited/nomad-logs-action
with:
token: ${{ secrets.YOUR_NOMAD_SECRET }}
address: ${{ secrets.YOUR_NOMAD_SERVER }}
job: example-job
Get logs from a parameterized job in a specific namespace and always complete successfully
name: Get logs from Nomad Job
on: [push]
jobs:
logs:
name: Nomad Logs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Get logs from Nomad
uses: younited/nomad-logs-action
with:
token: ${{ secrets.YOUR_NOMAD_SECRET }}
address: ${{ secrets.YOUR_NOMAD_SERVER }}
job: parameterized-job
namespace: my-namespace
parameterized: true
allow-stderr: true
Combine with vault-action
name: Get logs from Nomad Job
on: [push]
jobs:
logs:
name: Nomad Logs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Get Nomad token from Hashicorp Vault
uses: hashicorp/[email protected]
with:
url: ${{ secrets.YOUR_VAULT_SERVER }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: |
nomad/creds/github-action secret_id | NOMAD_TOKEN
- name: Get logs from Nomad
uses: younited/nomad-logs-action
with:
token: ${{ env.NOMAD_TOKEN }}
address: ${{ secrets.YOUR_NOMAD_SERVER }}
job: parameterized-job
namespace: my-namespace
parameterized: true
token
: Token used to authenticate with a nomad serveraddress
: Address of the nomad servernamespace
: Namespace of the nomad jobjob
: Name of the nomad jobparameterized
: Set to true if the nomad job is parameterizedallow-stderr
: Set to true so that the action completes successfully if logs are detected on stderr
status
: Indicates the success or failure of the running taskscontent
: Displays the task logs from stdout or stderr
Allocation "1abcd234" (group example-1):
✅ Task example-1 successfully deployed.
Allocation "4901ffe1" (group example-2):
✅ Task example-2 successfully deployed.
Allocation "ba54b3d9" (group example-1):
✅ Task example-1 successfully deployed.
Allocation "c41d3bc7" (group parameterized-1):
✅ Task parameterized_task_example successfully deployed:
<PARAMETERIZED JOB OUTPUT>
Allocation "47445981" (group example-1):
❌ Task example-1 failed:
2021/06/08 17:17:34 [emerg] 1#1: unknown directive "servre" in /etc/nginx/conf.d/status.conf:1
nginx: [emerg] unknown directive "servre" in /etc/nginx/conf.d/status.conf:1
Allocation "48bf3fc1" (group example-2):
✅ Task example-2 successfully deployed.
Allocation "5ab5c4d8" (group example-2):
❌ Task example-2 killed due to out-of-limit resources usage.
Allocation "490f2fc1" (group example-1):
✅ Task example-1 successfully deployed.
Allocation "d9f173e5" (group example-2):
❌ Task example-2 failed:
Failed to pull `nginx:1.19.4-oopsie`: API error (404): manifest for nginx:1.19.4-oopsie not found: manifest unknown: manifest unknown