Skip to content

Commit 2c50797

Browse files
authored
Merge pull request #1 from newrelic/feat/deployment-marker-action
feat: application deployment marker action
2 parents 6642417 + 4ab1322 commit 2c50797

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.md
2+
.gitignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM newrelic/cli:latest
2+
3+
# Copies your code file from your action repository to the filesystem path `/` of the container
4+
# COPY entrypoint.sh /entrypoint.sh
5+
COPY entrypoint.sh /entrypoint.sh
6+
7+
# Code file to execute when the docker container starts up (`entrypoint.sh`)
8+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# New Relic Application Deployment Marker
2+
New Relic App Deployment Marker
3+
4+
[![GitHub Marketplace version](https://img.shields.io/github/release/newrelic/deployment-marker-action.svg?label=Marketplace&logo=github)](https://github.com/marketplace/actions/new-relic-application-deployment-marker)
5+
6+
A GitHub Action to add New Relic deployment markers during your release pipeline.
7+
8+
## Inputs
9+
10+
| Key | | Description |
11+
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
12+
| `api_key` | required | Your New Relic [personal API key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key). |
13+
| `applicationId` | required | The New Relic application ID to apply the deployment marker. |
14+
| `region` | optional | The region of your New Relic account. Default: "US" |
15+
| `revision` | optional | Metadata to apply to the deployment marker - e.g. the latest release tag |
16+
| `accountId` | optional | The account number the application falls under. This could also be a subaccount. |
17+
18+
## Example usage
19+
20+
```yaml
21+
# Add a New Relic application deployment marker on release
22+
on:
23+
- release
24+
25+
jobs:
26+
release:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Apply New Relic deployment marker
30+
uses: sanderblue/newrelic-deployment-marker@master
31+
with:
32+
api_key: ${{ secrets.NEW_RELIC_API_KEY }}
33+
applicationId: <your application ID>
34+
revision: ${{ github.ref }}-${{ github.sha }} # optional
35+
region: US # optional
36+
accountId: <your New Relic account ID> # optional
37+
```

action.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'New Relic Application Deployment Marker'
2+
author: 'New Relic'
3+
description: 'Apply a New Relic application deployment marker to an application that is monitored by New Relic.'
4+
branding:
5+
icon: 'upload-cloud'
6+
color: 'blue'
7+
inputs:
8+
api_key:
9+
description: 'Your New Relic Personal API Key.'
10+
required: true
11+
region:
12+
description: 'The geographical region for your New Relic account - US or EU. Default: US'
13+
required: false
14+
default: US
15+
applicationId:
16+
description: 'The application ID to apply the deployment marker.'
17+
required: true
18+
revision:
19+
description: 'Custom revision information to add to the deployment marker - e.g. the latest tag.'
20+
required: false
21+
accountId:
22+
description: 'Your New Relic account ID. This account ID should have access to the specified application.'
23+
required: false
24+
runs:
25+
using: 'docker'
26+
image: 'Dockerfile'
27+
env:
28+
NEW_RELIC_API_KEY: ${{ inputs.api_key }}
29+
NEW_RELIC_REGION: ${{ inputs.region }}
30+
APPLICATION_ID: ${{ inputs.applicationId }}
31+
REVISION: ${{ inputs.revision }}
32+
ACCOUNT_ID: ${{ inputs.accountId }}

entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
RED='\033[0;31m'
4+
NO_COLOR='\033[0m'
5+
6+
result=$(newrelic apm deployment create --applicationId "${APPLICATION_ID}" --revision "${REVISION}" 2>&1)
7+
8+
exitStatus=$?
9+
10+
if [ $exitStatus -ne 0 ]; then
11+
printf "${RED}Error:${NO_COLOR} $result"
12+
fi
13+
14+
exit $exitStatus

0 commit comments

Comments
 (0)