Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GITHUB_REPOSITORY instead of context.repo() #7

Merged
merged 3 commits into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ class IssueCreator {
this.tools.log('Creating new issue')

// Create the new issue
return this.tools.github.issues.create(this.tools.context.repo({
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
return this.tools.github.issues.create({
owner,
repo,
...templated,
assignees: attributes.assignees || [],
labels: attributes.labels || [],
milestone: attributes.milestone
}))
})
}
}

Expand Down
50 changes: 35 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@
"env": [
"jest"
]
},
"jest": {
"setupFiles": [
"<rootDir>/tests/setup.js"
]
}
}
6 changes: 3 additions & 3 deletions tests/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Array [
"assignees": Array [
"JasonEtco",
],
"body": "The repo waddup is the best repo.",
"body": "The action create-an-issue is the best action.",
"labels": Array [
"bugs",
],
Expand All @@ -41,12 +41,12 @@ Array [
Array [
Object {
"assignees": Array [],
"body": "The repo waddup is the best repo.",
"body": "The action create-an-issue is the best action.",
"labels": Array [],
"milestone": undefined,
"owner": "JasonEtco",
"repo": "waddup",
"title": "Hello JasonEtco",
"title": "Hello create-an-issue",
},
],
]
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/.github/kitchen-sink.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ labels:
- bugs
milestone: 2
---
The repo {{ payload.repository.name }} is the best repo.
The action {{ action }} is the best action.
4 changes: 2 additions & 2 deletions tests/fixtures/.github/variables.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Hello {{ payload.repository.owner.login }}
title: Hello {{ action }}
---
The repo {{ payload.repository.name }} is the best repo.
The action {{ action }} is the best action.
1 change: 0 additions & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('create-an-issue', () => {
github = { issues: { create: jest.fn() } }

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

issueCreator = new IssueCreator(tools)
Expand Down
4 changes: 4 additions & 0 deletions tests/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Object.assign(process.env, {
'GITHUB_REPOSITORY': 'JasonEtco/waddup',
'GITHUB_ACTION': 'create-an-issue'
})