Skip to content

Commit 5bcf505

Browse files
author
Jonathan Thurman
authored
Merge pull request #9 from newrelic/jthurman/release-tags
Make accountId required, update flows and docs
2 parents 3c31b58 + abca3e4 commit 5bcf505

File tree

10 files changed

+294
-35
lines changed

10 files changed

+294
-35
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{ if .Versions -}}
2+
{{ if .Unreleased.CommitGroups -}}
3+
<a name="unreleased"></a>
4+
## [Unreleased]
5+
6+
{{ range .Unreleased.CommitGroups -}}
7+
### {{ .Title }}
8+
{{ range .Commits -}}
9+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
10+
{{ end }}
11+
{{ end -}}
12+
{{ end -}}
13+
14+
{{ range .Versions -}}
15+
<a name="{{ .Tag.Name }}"></a>
16+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
17+
{{ range .CommitGroups -}}
18+
### {{ .Title }}
19+
{{ range .Commits -}}
20+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
21+
{{ end }}
22+
{{ end -}}
23+
24+
{{ if .NoteGroups -}}
25+
{{ range .NoteGroups -}}
26+
### {{ .Title }}
27+
{{ range .Notes }}
28+
{{ .Body }}
29+
{{ end }}
30+
{{ end -}}
31+
{{ end -}}
32+
{{ end -}}
33+
34+
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
35+
{{ range .Versions -}}
36+
{{ if .Tag.Previous -}}
37+
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
38+
{{ end -}}
39+
{{ end -}}
40+
{{ end -}}

.chglog/config.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/newrelic/deployment-marker-action
6+
options:
7+
commits:
8+
filters:
9+
Type:
10+
- docs
11+
- feat
12+
- fix
13+
14+
commit_groups:
15+
title_maps:
16+
docs: Documentation Updates
17+
feat: Features
18+
fix: Bug Fixes
19+
20+
refs:
21+
actions:
22+
- Closes
23+
- Fixes
24+
- Resolves
25+
26+
issues:
27+
prefix:
28+
- #
29+
30+
header:
31+
pattern: "^(\\w*)(?:\\(([\\/\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
32+
pattern_maps:
33+
- Type
34+
- Scope
35+
- Subject
36+
37+
notes:
38+
keywords:
39+
- BREAKING CHANGE

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
- release
75

86
jobs:
97
basic_test:
108
runs-on: ubuntu-latest
11-
name: Release marker example
9+
name: Deployment marker example
1210
steps:
1311
- name: Checkout
1412
uses: actions/checkout@v2
@@ -20,6 +18,7 @@ jobs:
2018
uses: ./
2119
with:
2220
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
23-
applicationId: ${{ secrets.APPLICATION_ID }}
24-
revision: "deployment-marker-action-release:${{ env.RELEASE_VERSION }}"
21+
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
22+
applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID }}
23+
revision: "${{ github.repository }}:${{ env.RELEASE_VERSION }}"
2524

.github/workflows/test.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
# uses: ./
1919
# with:
2020
# apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
21+
# accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
2122
# applicationId: 0
2223
# revision: "deployment-marker-action-should-fail-test:${{ github.ref }}"
2324

@@ -31,6 +32,7 @@ jobs:
3132
- name: Test deployment marker
3233
uses: ./
3334
with:
35+
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
3436
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
3537
applicationId: ${{ secrets.APPLICATION_ID }}
3638
revision: "deployment-marker-action-basic-test:${{ github.ref }}"
@@ -45,10 +47,14 @@ jobs:
4547
- name: Test deployment marker
4648
uses: ./
4749
with:
50+
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
4851
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
4952
applicationId: ${{ secrets.APPLICATION_ID }}
5053
revision: "deployment-marker-action-all-input-test-${{ github.sha }}"
51-
user: "hardcoded-test-username" # optional
52-
region: US # optional
53-
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} # optional
54+
55+
# Optional
56+
changelog: "See https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md for details"
57+
description: "Automated Deployment via Github Actions"
58+
region: ${{ secrets.NEW_RELIC_REGION }}
59+
user: "hardcoded-test-username"
5460

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<a name="unreleased"></a>
2+
## [Unreleased]
3+
4+
### Bug Fixes
5+
- **vars:** Make accountId required, update flows and docs
6+
7+
### Features
8+
- Add description and changelog optional attributes
9+
10+
<a name="v0.2.0"></a>
11+
## [v0.2.0] - 2020-05-21
12+
### Bug Fixes
13+
- **errors:** Echo using GH Error interface (resolves [#3](https://github.com/newrelic/deployment-marker-action/issues/3))
14+
15+
<a name="v0.1.2"></a>
16+
## [v0.1.2] - 2020-05-20
17+
### Bug Fixes
18+
- wrap github.actor context in quotes, update example, add test workflow
19+
20+
<a name="v0.1.1"></a>
21+
## [v0.1.1] - 2020-05-19
22+
### Bug Fixes
23+
- consistent naming convention style for input attributes
24+
25+
<a name="v0.1.0"></a>
26+
## [v0.1.0] - 2020-05-19
27+
### Bug Fixes
28+
- use correct action reference in example
29+
30+
### Features
31+
- pass account ID to the deployment request
32+
- add ability to associate a user to a deployment
33+
34+
<a name="v0.0.1"></a>
35+
## v0.0.1 - 2020-05-18
36+
### Bug Fixes
37+
- adjust URL for market badge
38+
39+
### Documentation Updates
40+
- minor update for the example
41+
42+
### Features
43+
- New Relic deployment marker action
44+
45+
[Unreleased]: https://github.com/newrelic/deployment-marker-action/compare/v0.2.0...HEAD
46+
[v0.2.0]: https://github.com/newrelic/deployment-marker-action/compare/v0.1.2...v0.2.0
47+
[v0.1.2]: https://github.com/newrelic/deployment-marker-action/compare/v0.1.1...v0.1.2
48+
[v0.1.1]: https://github.com/newrelic/deployment-marker-action/compare/v0.1.0...v0.1.1
49+
[v0.1.0]: https://github.com/newrelic/deployment-marker-action/compare/v0.0.1...v0.1.0

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#############################
2+
# Global vars
3+
#############################
4+
PROJECT_NAME := $(shell basename $(shell pwd))
5+
PROJECT_VER ?= $(shell git describe --tags --always --dirty | sed -e '/^v/s/^v\(.*\)$$/\1/g')
6+
# Last released version (not dirty) without leading v
7+
PROJECT_VER_TAGGED := $(shell git describe --tags --always --abbrev=0 | sed -e '/^v/s/^v\(.*\)$$/\1/g')
8+
9+
SRCDIR ?= .
10+
RELEASE_SCRIPT ?= ./scripts/release.sh
11+
12+
all:
13+
@echo "=== $(PROJECT_NAME) === [ all ]: Supported targets:"
14+
@echo " release - Create new release"
15+
16+
17+
# Example usage: make release version=0.11.0
18+
release:
19+
@echo "=== $(PROJECT_NAME) === [ release ]: Generating release."
20+
$(RELEASE_SCRIPT) $(version)
21+
22+
23+
.PHONY: all build

README.md

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,83 @@ A GitHub Action to add New Relic deployment markers during your release pipeline
88

99
## Inputs
1010

11-
| Key | | Description |
12-
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
13-
| `apiKey` | 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). |
14-
| `applicationId` | required | The New Relic application ID to apply the deployment marker. |
15-
| `revision` | required | Metadata to apply to the deployment marker - e.g. the latest release tag |
16-
| `user` | optional | The user creating the deployment. Default: `github.actor` |
17-
| `region` | optional | The region of your New Relic account. Default: `US` |
18-
| `accountId` | optional | The account number the application falls under. This could also be a subaccount. |
11+
| Key | Required | Default | Description |
12+
| --------------- | -------- | ------- | ----------- |
13+
| `accountId` | **yes** | - | The account number the application falls under. This could also be a subaccount. |
14+
| `apiKey` | **yes** | - | Your New Relic [personal API key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key). |
15+
| `applicationId` | **yes** | - | The New Relic application ID to apply the deployment marker. |
16+
| `changelog` | no | - | A summary of what changed in this deployment, visible in the Deployments page. |
17+
| `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. |
18+
| `region` | no | `US` | The region of your New Relic account. Default: `US` |
19+
| `revision` | **yes** | - | Metadata to apply to the deployment marker - e.g. the latest release tag |
20+
| `user` | no | `github.actor` | A username to associate with the deployment, visible in the Overview page and on the Deployments page. |
1921

2022
## Example usage
2123

24+
#### Use Release Tag for Revision
25+
26+
The following example could be added as a job to your existing workflow that
27+
creates a New Relic deployment marker with the revision being the release Tag.
28+
29+
Github secrets assumed to be set:
30+
* `NEW_RELIC_ACCOUNT_ID` - Personal API key
31+
* `NEW_RELIC_API_KEY` - Personal API key
32+
* `NEW_RELIC_APPLIATION_ID` - New Relic Application ID to create the marker on
33+
2234
```yaml
23-
# Add a New Relic application deployment marker on release
35+
name: Release
36+
2437
on:
2538
- release
2639

2740
jobs:
28-
release:
41+
newrelic:
2942
runs-on: ubuntu-latest
43+
name: New Relic
3044
steps:
31-
- name: Apply New Relic deployment marker
32-
uses: newrelic/deployment-marker-action@master
45+
- name: Set Release Version from Tag
46+
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}
47+
48+
- name: Create New Relic deployment marker
49+
uses: newrelic/deployment-marker-action@v1
3350
with:
3451
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
35-
applicationId: <your application ID>
52+
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
53+
applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID }}
54+
revision: "${{ env.RELEASE_VERSION }}"
55+
```
56+
57+
#### All input options
58+
59+
Add a New Relic application deployment marker on release, with all of the
60+
options set.
61+
62+
Github secrets assumed to be set:
63+
* `NEW_RELIC_ACCOUNT_ID` - New Relic Account ID the application is reporting to
64+
* `NEW_RELIC_API_KEY` - Personal API key
65+
* `NEW_RELIC_APPLIATION_ID` - New Relic Application ID to create the marker on
66+
67+
```yaml
68+
name: Release
69+
on:
70+
- release
71+
72+
jobs:
73+
newrelic:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Create New Relic deployment marker
77+
uses: newrelic/deployment-marker-action@v1
78+
with:
79+
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
80+
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
81+
applicationId: ${{ secrets.NEW_RELIC_APPLIATION_ID }}
3682
revision: "${{ github.ref }}-${{ github.sha }}"
37-
user: "${{ github.actor }}" # optional
38-
region: US # optional
39-
accountId: <your New Relic account ID> # optional
83+
84+
# Optional
85+
changelog: "See https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md for details"
86+
description: "Automated Deployment via Github Actions"
87+
region: ${{ secrets.NEW_RELIC_REGION }}
88+
user: "${{ github.actor }}"
4089
```
90+

action.yaml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@ inputs:
88
apiKey:
99
description: 'Your New Relic Personal API Key.'
1010
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
11+
accountId:
12+
description: 'Your New Relic account ID. This account ID should have access to the specified application.'
13+
required: true
1514
applicationId:
1615
description: 'The application ID to apply the deployment marker.'
1716
required: true
1817
revision:
1918
description: 'Custom revision information to add to the deployment marker - e.g. the latest tag.'
2019
required: true
21-
accountId:
22-
description: 'Your New Relic account ID. This account ID should have access to the specified application.'
20+
region:
21+
description: 'The geographical region for your New Relic account - US or EU. Default: US'
22+
required: false
23+
default: US
24+
description:
25+
description: 'Description stored with the deployment. Default: <none>'
26+
required: false
27+
changelog:
28+
description: 'Change log string stored with the deployment. Default: <none>'
2329
required: false
2430
user:
2531
description: 'The user creating the deployment. Default: `github.actor`'
@@ -30,8 +36,10 @@ runs:
3036
image: 'Dockerfile'
3137
env:
3238
NEW_RELIC_API_KEY: ${{ inputs.apiKey }}
33-
NEW_RELIC_REGION: ${{ inputs.region }}
34-
APPLICATION_ID: ${{ inputs.applicationId }}
35-
REVISION: ${{ inputs.revision }}
3639
NEW_RELIC_ACCOUNT_ID: ${{ inputs.accountId }}
40+
NEW_RELIC_APPLICATION_ID: ${{ inputs.applicationId }}
41+
NEW_RELIC_REGION: ${{ inputs.region }}
3742
NEW_RELIC_DEPLOYMENT_USER: ${{ inputs.user }}
43+
NEW_RELIC_DEPLOYMENT_REVISION: ${{ inputs.revision }}
44+
NEW_RELIC_DEPLOYMENT_CHANGE_LOG: ${{ inputs.changelog }}
45+
NEW_RELIC_DEPLOYMENT_DESCRIPTION: ${{ inputs.description }}

entrypoint.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/bin/sh
22

3-
result=$(newrelic apm deployment create --applicationId "${APPLICATION_ID}" --revision "${REVISION}" --accountId "${NEW_RELIC_ACCOUNT_ID}" --user "${NEW_RELIC_DEPLOYMENT_USER}" 2>&1)
3+
result=$(newrelic apm deployment create \
4+
--accountId "${NEW_RELIC_ACCOUNT_ID}" \
5+
--applicationId "${NEW_RELIC_APPLICATION_ID}" \
6+
--user "${NEW_RELIC_DEPLOYMENT_USER}" \
7+
--revision "${NEW_RELIC_DEPLOYMENT_REVISION}" \
8+
--change-log "${NEW_RELIC_DEPLOYMENT_CHANGE_LOG}" \
9+
--description "${NEW_RELIC_DEPLOYMENT_DESCRIPTION}" \
10+
2>&1)
411

512
exitStatus=$?
613

0 commit comments

Comments
 (0)