Code Monkey home page Code Monkey logo

deployment-marker-action's Introduction

Community Project header

New Relic Application Deployment Marker

GitHub Marketplace version

A GitHub Action to add New Relic deployment markers during your release pipeline.

Inputs

Key Required Default Description
guid yes - The entity GUID to apply the deployment marker.
apiKey yes - Your New Relic personal API key.
changelog no - A summary of what changed in this deployment, visible in the Deployments page.
commit no - The Commit SHA for this deployment, visible in the Deployments page.
description no - A high-level description of this deployment, visible in the Overview page and on the Deployments page when you select an individual deployment.
deepLink no - A deep link to the source which triggered the deployment.
deploymentType no BASIC The type of deployment. Choose from BASIC, BLUE_GREEN, CANARY, OTHER, ROLLING, or SHADOW.
groupId no - A group ID for the deployment to link to other deployments.
region no US The region of your New Relic account. Default: US
version yes - Metadata to apply to the deployment marker - e.g. the latest release tag
user yes github.actor A username to associate with the deployment, visible in the Overview page and on the Deployments page.

Example usage

GitHub secrets

Github secrets assumed to be set:

  • NEW_RELIC_API_KEY - Personal API key
  • NEW_RELIC_DEPLOYMENT_ENTITY_GUID - New Relic Entity GUID to create the marker on

There are a number of default GitHub environment variables that are used in these examples as well.

Minimum required fields

name: Change Tracking Marker
on:
  - release
      types: [published]

jobs:
  newrelic:
    runs-on: ubuntu-latest
    name: New Relic
    steps:
      # This step builds a var with the release tag value to use later
      - name: Set Release Version from Tag
        run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
      # This step creates a new Change Tracking Marker
      - name: New Relic Application Deployment Marker
        uses: newrelic/[email protected]
        with:
          apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
          region: "US"
          guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID }}
          version: "${{ env.RELEASE_VERSION }}"
          user: "${{ github.actor }}"

All input fields

In addition to NEW_RELIC_API_KEY, this example shows how to target multiple items by storing multiple secrets like "NEW_RELIC_DEPLOYMENT_ENTITY_GUID_<ID>", where <ID> is the unique identifier for the target item.

NEW_RELIC_DEPLOYMENT_ENTITY_GUID_App123
NEW_RELIC_DEPLOYMENT_ENTITY_GUID_App456
NEW_RELIC_DEPLOYMENT_ENTITY_GUID_App789
name: Change Tracking Marker
on:
  workflow_dispatch:
  release:
    types: [published]

jobs:
  newrelic:
    runs-on: ubuntu-latest
    name: New Relic
    steps:
      # This step builds a var with the release tag value to use later
      - name: Set Release Version from Tag
        run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
      # This step creates a new Change Tracking Marker for App123
      - name: App123 Marker
        uses: newrelic/[email protected]
        with:
          apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
          region: "US"
          guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID_App123 }}
          version: "${{ env.RELEASE_VERSION }}"
          changelog: "https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md"
          commit: "${{ github.sha }}"
          description: "Automated Release via Github Actions"
          deploymenttype: "ROLLING"
          groupId: "Workshop App Release: ${{ github.ref_name }}"
          user: "${{ github.actor }}"
      # This step creates a new Change Tracking Marker for App
      - name: App456 Marker
        uses: newrelic/[email protected]
        with:
          apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
          region: "US"
          guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID_App456 }}
          version: "${{ env.RELEASE_VERSION }}"
          changelog: "https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md"
          commit: "${{ github.sha }}"
          description: "Automated Release via Github Actions"
          deploymenttype: "ROLLING"
          groupId: "Workshop App Release: ${{ github.ref_name }}"
          user: "${{ github.actor }}"
      # This step creates a new Change Tracking Marker for App789
      - name: App789 Marker
        uses: newrelic/[email protected]
        with:
          apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
          region: "US"
          guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID_App789 }}
          version: "${{ env.RELEASE_VERSION }}"
          changelog: "https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md"
          commit: "${{ github.sha }}"
          description: "Automated Release via Github Actions"
          deploymenttype: "ROLLING"
          groupId: "Workshop App Release: ${{ github.ref_name }}"
          user: "${{ github.actor }}"
      # When chaining steps together, the deployment id is placeed into the github environment 
      - name: View output
        run: echo "${{ env.deploymentId }}"

deployment-marker-action's People

Contributors

amolero-nr avatar b0go avatar barryhagan avatar justinlewisnr avatar mbazhlekova avatar mrkimbo avatar pranav-new-relic avatar sanderblue avatar stephengoodall avatar thezackm avatar tijmenb avatar zlesnr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deployment-marker-action's Issues

Question or feature request: Why we can't use service name instead of GUID?

The action requests "The entity GUID to apply the deployment marker" for each deploy event. It means I have to collect a list of GUIDs for all services across all environments and use them in my workflow.

But we already have a 'service name' in both NewRelic and GH workflow. So why don't use it instead of GUID for calling this action?

action failing with 'Cannot query field "customAttributes" on type "ChangeTrackingDeployment"' error

I'm using newrelic/[email protected] and earlier today action runs started failing with the message Error: level=fatal msg="Cannot query field \"customAttributes\" on type \"ChangeTrackingDeployment\".". Here is the log for the step:

2023-10-30T18:52:16.4224730Z ##[group]Run newrelic/[email protected]
2023-10-30T18:52:16.4225273Z with:
2023-10-30T18:52:16.4225685Z   apiKey: ***
2023-10-30T18:52:16.4226082Z   commit: 907328f41047766fe14794f81f92b19304b1427d
2023-10-30T18:52:16.4226594Z   deploymentType: BLUE_GREEN
2023-10-30T18:52:16.4227026Z   description: Github Actions Deploy
2023-10-30T18:52:16.4227504Z   groupId: Github Actions Deploy: main
2023-10-30T18:52:16.4228093Z   guid: ***
2023-10-30T18:52:16.4228398Z   user: benburkert
2023-10-30T18:52:16.4228729Z   version: main
2023-10-30T18:52:16.4229056Z   region: US
2023-10-30T18:52:16.4229357Z env:
2023-10-30T18:52:16.4229836Z   NEW_RELIC_GUID: ***
2023-10-30T18:52:16.4230202Z ##[endgroup]
2023-10-30T18:52:16.4530785Z ##[command]/usr/bin/docker run --name b835f03f612be9e5438aacffd18e69ecdf55_d1258d --label 47b835 --workdir /github/workspace --rm -e "NEW_RELIC_GUID" -e "INPUT_APIKEY" -e "INPUT_COMMIT" -e "INPUT_DEPLOYMENTTYPE" -e "INPUT_DESCRIPTION" -e "INPUT_GROUPID" -e "INPUT_GUID" -e "INPUT_USER" -e "INPUT_VERSION" -e "INPUT_REGION" -e "INPUT_CHANGELOG" -e "INPUT_DEEPLINK" -e "NEW_RELIC_API_KEY" -e "NEW_RELIC_DEPLOYMENT_ENTITY_GUID" -e "NEW_RELIC_REGION" -e "NEW_RELIC_DEPLOYMENT_USER" -e "NEW_RELIC_DEPLOYMENT_VERSION" -e "NEW_RELIC_DEPLOYMENT_CHANGE_LOG" -e "NEW_RELIC_DEPLOYMENT_COMMIT" -e "NEW_RELIC_DEPLOYMENT_DESCRIPTION" -e "NEW_RELIC_DEPLOYMENT_DEEPLINK" -e "NEW_RELIC_DEPLOYMENT_TYPE" -e "NEW_RELIC_DEPLOYMENT_GROUP_ID" -e "NEW_RELIC_SERVICE_NAME" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/anchor/anchor":"/github/workspace" 47b835:f03f612be9e5438aacffd18e69ecdf55
2023-10-30T18:52:18.1942844Z level=fatal msg="Cannot query field \"customAttributes\" on type \"ChangeTrackingDeployment\"."
2023-10-30T18:52:18.2064726Z ##[error] level=fatal msg="Cannot query field \"customAttributes\" on type \"ChangeTrackingDeployment\"."

And here is what my action yml config looks like:

      - name: "Deploys: anchord New Relic deploy marker"
        env:
          NEW_RELIC_GUID: ${{ secrets.NEW_RELIC_BE_ANCHORD_PRD_GUID }}
        if: env.NEW_RELIC_GUID != ''
        uses: newrelic/[email protected]
        with:
          apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
          commit: ${{ github.sha }}
          deploymentType: "BLUE_GREEN"
          description: "Github Actions Deploy"
          groupId: "Github Actions Deploy: ${{ github.ref_name }}"
          guid: ${{ env.NEW_RELIC_GUID }}
          user: ${{ github.actor }}
          version: ${{ github.ref_name }}

The config hasn't changed recently and, as far as I know, the credentials are still valid.

Action fails but is marked as success

If the credentials are wrong, the GitHub Action shows an error on the logs but the job status is still displayed as successful. The job should instead be marked as a failure so it would be easier to fix the credentials and re-run just the failed jobs instead of the whole flow.

Workflow usage:

jobs:
  # ...
  deployment-marker:
    name: Create deployment marker
    needs: deploy
    runs-on: ubuntu-latest
    steps:
      - name: Retrieve release version
        run:
          echo "RELEASE_VERSION=$(echo ${{ github.event.ref }} | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+$')" >> $GITHUB_ENV

      - name: Create deployment marker on New Relic
        uses: newrelic/[email protected]
        with:
          guid: ${{ secrets.PRODUCTION_NEW_RELIC_GUID }}
          apiKey: ${{ secrets.PRODUCTION_NEW_RELIC_API_KEY }}
          region: "EU"
          version: "${{ env.RELEASE_VERSION }}"
          user: "${{ github.actor }}"

Example when wrong credentials are provided:

Log shown

level=fatal msg="Argument \"deployment\" has invalid value $deployment.\nIn field \"entityGuid\": Expected type \"EntityGuid!\", found \"***\"."

Job status returned

SUCCESS ✅

Job status expected

FAILURE ❌

Action fails with "Unrecognized named-value 'github'"

First of all, SUPER cool that there is now an officially supported github action!

I decided to try it out, but unfortunately my action fails to run with the following error in the setup job:

##[error](Line: 25, Col: 18): Unrecognized named-value: 'github'. Located at position 1 within expression: github.actor
##[error]Fail to load /home/runner/work/_actions/newrelic/deployment-marker-action/master/action.yaml

If I'm reading this right, perhaps the description for the user input is trying to parse a value rather than using the literal string value?

New Relic Markers clarification on timelines

Hi, what's the expected behavior for Markers?

Ideally, they should have a beginning/start/completion and failure but you can only register that once.

For a rollout/canary deployment, when should you send the request to the new relic? Before you start the deployment or after? if you do it before, it's more likely any error behavior will be correlated with the beginning of the rollout, but if I do it after, it might not be very clear, especially on long canary deployments.

Action is not working for manual run(workflow_dispatch) actions

We have created a git action of type workflow_dispatch and integrated deployment-marker-action. When executing it manually it is not working, but works fine with release workflow.

Error we are getting:

level=fatal msg="could not initialize New Relic client, make sure your profile is configured with newrelic profile configure"

Please confirm if this workflow is designed for only
release:
types: [published]

NRQL query for deployment marker

Is there option to use New Relic NRQL query to customize deployment markers only for marking the 'running' state pods rather than marking every depoyment?

NRQL to use: FROM Metric SELECT latest(if(k8s.pod.isReady = 1, 'True', 'False')) as 'Ready' WHERE entity.guid = 'MjAzMzk5NXxJTkZSQXxOQXw2NTk3NjM2NTUwNTgzNzM0ODY2'

How to debug 403 response returned?

I get the following error: "level=error msg="403 response returned"

When using:

Run newrelic/deployment-marker-action@v1
with:
accountId: ***
apiKey: ***
applicationId: ***
revision: refs/heads/main-2241c0c22f87387a02a8334fcacd1084a7502782
description: Automated Deployment via Github Actions
region: US
user: kerim1510

Minimum required fields documentation incorrect

The fields documented are prompting an error. I guess it should be:

name: Change Tracking Marker
on:
  release:
    types: [published]

jobs:
  newrelic:
    runs-on: ubuntu-latest
    name: New Relic
    steps:
      # This step builds a var with the release tag value to use later
      - name: Set Release Version from Tag
        run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
      # This step creates a new Change Tracking Marker
      - name: New Relic Application Deployment Marker
        uses: newrelic/[email protected]
        with:
          apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
          region: "US"
          guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID }}
          version: "${{ env.RELEASE_VERSION }}"
          user: "${{ github.actor }}"

Two identical workflows, one works, the other errors out

I have one workflow used to deploy, and at the end it runs this NR deployment marker Action

I run it alternately in two GHA "Environments" -- QA and PROD

each env receives a different NR GUID via an per-env environment variable

The first one, QA, works fine

For PROD runs of this workflow, I get this weird error

Error:  level=fatal msg="Argument \"deployment\" has invalid value $deployment.\nIn field \"entityGuid\": Expected type \"EntityGuid!\", found \"MzQ........................................1NQ\\r\"."

The two Environments run the same workflow the same way; the only difference is the GUID. I have several debug steps to validate the values of all the required env vars and secrets and they look fine.

I tried running this action locally (i.e. on my workstation) following the docker build steps and env var scaffolding that seem to happen inside GHA and I never get this error. I also rebuilt locally with the --debug flag but since i could not reproduce the error, that wasn't super helpful.

I browsed the NR CLI codebase as well (https://github.com/newrelic/newrelic-cli) trying to find what would be causing this error but nothing obvious comes up.

The second part of this error implies to me that there is an empty or shifted field somewhere. But I can't find it. I also don't really understand the first part of the error -- there is no field or variable named $deployment anywhere. There is a field $deploymenttype, but that doesn't match up.

Any help is appreciated. Is there a way to enable debugging on this action?

Recommendation for deployment markers in containerized environment (Fargate)

I'm using Github actions to deploy new versions of our Fargate tasks into our Production cluster when we "release". NewRelic is being used to track metrics and logs for these containers, but I was wondering what would make sense in terms of displaying deployment versions / demarcation lines -- similar to what is being done for the APM app deployments. I'm not sure if this is possible but I was hoping for guidance on seeing these lines in the "Summary" view for the production containers.

could not initialize New Relic client

We are getting the following when trying to create a marker for our app in GitHub Actions:

level=fatal msg="could not initialize New Relic client, make sure your profile is configured with newrelic profile configure"

This is the step configuration we have:

    - name: Create New Relic OTEL Application Deployment Marker
      if: ${{ steps.guid_otel.outputs.guid != '' }}
      uses: newrelic/[email protected]
      with:
        apiKey: ${{ secrets.api_key }}
        region: "EU"
        guid: ${{ steps.guid_otel.outputs.guid }}
        version: ${{ steps.version.outputs.version }}
        deeplink: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
        user: "${{ github.actor }}"

We've had markers working some time before, so I don't know what has happened.

Not specifying a region can lead to confusing error message

Over the last couple of days I spent a lot longer than I'd like to admit trying to set up this GitHub Action. The reason for this is that I used the first example from the README. I kept running into a 403 response returned error:

Screenshot 2021-11-03 at 09 58 26

At first I assumed this was due to a incorrect API key (so I tried a Ingestion key and a legacy REST key). Eventually I figured out that because our account is EU, the API request fails because it defaults the region to US.

To avoid other people running into the same issue, I wonder if the workflow could output a more informative error message for this 403? Or alternatively, could we make the region required?

Ability to send multiple guid in the same call

Because Github actions don't allow for a loop of multiple steps in the same job, the only way to properly configure multiple calls is to use a matrix.

But because this step takes a few seconds, while GitHub charges for the minute and up, someone would be wasting the remaining set of seconds of the minute.

Ideally, guid should work with:

guid: guid-example

or

guid: guid1, guid2, guid3

This is useful when someone is deploying a set of resources in the same deployment. Ex:

  • APM app
  • k8s deployment
  • lambda change
  • database update

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.