Skip to content

Commit 64520c0

Browse files
authored
Merge pull request #7 from JasonEtco/use-github-repo-env
Use GITHUB_REPOSITORY instead of context.repo()
2 parents 3b32e1e + 891fc6c commit 64520c0

File tree

8 files changed

+55
-24
lines changed

8 files changed

+55
-24
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ class IssueCreator {
3636
this.tools.log('Creating new issue')
3737

3838
// Create the new issue
39-
return this.tools.github.issues.create(this.tools.context.repo({
39+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
40+
return this.tools.github.issues.create({
41+
owner,
42+
repo,
4043
...templated,
4144
assignees: attributes.assignees || [],
4245
labels: attributes.labels || [],
4346
milestone: attributes.milestone
44-
}))
47+
})
4548
}
4649
}
4750

package-lock.json

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

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@
2323
"env": [
2424
"jest"
2525
]
26+
},
27+
"jest": {
28+
"setupFiles": [
29+
"<rootDir>/tests/setup.js"
30+
]
2631
}
2732
}

tests/__snapshots__/index.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Array [
2323
"assignees": Array [
2424
"JasonEtco",
2525
],
26-
"body": "The repo waddup is the best repo.",
26+
"body": "The action create-an-issue is the best action.",
2727
"labels": Array [
2828
"bugs",
2929
],
@@ -41,12 +41,12 @@ Array [
4141
Array [
4242
Object {
4343
"assignees": Array [],
44-
"body": "The repo waddup is the best repo.",
44+
"body": "The action create-an-issue is the best action.",
4545
"labels": Array [],
4646
"milestone": undefined,
4747
"owner": "JasonEtco",
4848
"repo": "waddup",
49-
"title": "Hello JasonEtco",
49+
"title": "Hello create-an-issue",
5050
},
5151
],
5252
]

tests/fixtures/.github/kitchen-sink.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ labels:
66
- bugs
77
milestone: 2
88
---
9-
The repo {{ payload.repository.name }} is the best repo.
9+
The action {{ action }} is the best action.

tests/fixtures/.github/variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
title: Hello {{ payload.repository.owner.login }}
2+
title: Hello {{ action }}
33
---
4-
The repo {{ payload.repository.name }} is the best repo.
4+
The action {{ action }} is the best action.

tests/index.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ describe('create-an-issue', () => {
1515
github = { issues: { create: jest.fn() } }
1616

1717
tools.workspace = path.join(__dirname, 'fixtures')
18-
tools.context.payload = { repository: { owner: { login: 'JasonEtco' }, name: 'waddup' } }
1918
tools.github = github
2019

2120
issueCreator = new IssueCreator(tools)

tests/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Object.assign(process.env, {
2+
'GITHUB_REPOSITORY': 'JasonEtco/waddup',
3+
'GITHUB_ACTION': 'create-an-issue'
4+
})

0 commit comments

Comments
 (0)