Skip to content

Commit 7f1894f

Browse files
committed
include version in requests
1 parent 5577504 commit 7f1894f

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

__tests__/version.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {VERSION} from '../src/version'
2+
3+
describe('VERSION constant', () => {
4+
const versionRegex = /^v(\d+)\.(\d+)\.(\d+)(?:-rc\.(\d+))?$/
5+
6+
it('should match the version pattern', () => {
7+
expect(VERSION).toMatch(versionRegex)
8+
})
9+
10+
it('should validate v1.0.0', () => {
11+
const version = 'v1.0.0'
12+
expect(version).toMatch(versionRegex)
13+
})
14+
15+
it('should validate v4.5.1', () => {
16+
const version = 'v4.5.1'
17+
expect(version).toMatch(versionRegex)
18+
})
19+
20+
it('should validate v10.123.44', () => {
21+
const version = 'v10.123.44'
22+
expect(version).toMatch(versionRegex)
23+
})
24+
25+
it('should validate v1.1.1-rc.1', () => {
26+
const version = 'v1.1.1-rc.1'
27+
expect(version).toMatch(versionRegex)
28+
})
29+
30+
it('should validate v15.19.4-rc.35', () => {
31+
const version = 'v15.19.4-rc.35'
32+
expect(version).toMatch(versionRegex)
33+
})
34+
})

dist/index.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/post.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as github from '@actions/github'
44
import {context} from '@actions/github'
55
import {postReactions} from './post-reactions'
66
import {octokitRetry} from '@octokit/plugin-retry'
7+
import {VERSION} from '../version'
78

89
// Default failure reaction
910
const thumbsDown = '-1'
@@ -38,6 +39,7 @@ export async function post() {
3839

3940
// Create an octokit client with the retry plugin
4041
const octokit = github.getOctokit(token, {
42+
userAgent: `github/command@${VERSION}`,
4143
additionalPlugins: [octokitRetry]
4244
})
4345

src/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import {actionStatus} from './functions/action-status'
1010
import {prechecks} from './functions/prechecks'
1111
import {post} from './functions/post'
1212
import {COLORS} from './functions/colors'
13+
import {VERSION} from './version'
1314

1415
// :returns: 'success', 'failure', 'safe-exit' or raises an error
1516
export async function run() {
1617
try {
18+
core.info(`🛸 github/command ${COLORS.info}${VERSION}${COLORS.reset}`)
1719
// Get the inputs for the 'command' Action
1820
const command = core.getInput('command', {required: true})
1921
const token = core.getInput('github_token', {required: true})
@@ -26,6 +28,7 @@ export async function run() {
2628

2729
// create an octokit client with the retry plugin
2830
const octokit = github.getOctokit(token, {
31+
userAgent: `github/command@${VERSION}`,
2932
additionalPlugins: [octokitRetry]
3033
})
3134

0 commit comments

Comments
 (0)