Giter Site home page Giter Site logo

nomad-logs-action's Introduction

nomad-logs-action

Small GitHub Action that makes requests to a Hashicorp Nomad server and collects logs from a given job.

Usage

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

Parameters

  • token: Token used to authenticate with a nomad server
  • address: Address of the nomad server
  • namespace: Namespace of the nomad job
  • job: Name of the nomad job
  • parameterized: Set to true if the nomad job is parameterized
  • allow-stderr: Set to true so that the action completes successfully if logs are detected on stderr

Outputs

  • status: Indicates the success or failure of the running tasks
  • content: Displays the task logs from stdout or stderr

Example of displayed logs

Success (service job)

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.

Success (parameterized job)

Allocation "c41d3bc7" (group parameterized-1):
✅ Task parameterized_task_example successfully deployed:
<PARAMETERIZED JOB OUTPUT>

Error

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.

Out of Memory

Allocation "5ab5c4d8" (group example-2):
❌ Task example-2 killed due to out-of-limit resources usage.

Docker Driver Error

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

nomad-logs-action's People

Contributors

dysonfrost avatar bertg avatar

Watchers

 avatar Buts Johan avatar James Cloos avatar  avatar

nomad-logs-action's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.