Skip to content

Commit

Permalink
Merge pull request #7 from JasonEtco/use-github-repo-env
Browse files Browse the repository at this point in the history
Use GITHUB_REPOSITORY instead of context.repo()
  • Loading branch information
JasonEtco committed Mar 30, 2019
2 parents 3b32e1e + 891fc6c commit 64520c0
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 24 deletions.
7 changes: 5 additions & 2 deletions index.js
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
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
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
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
@@ -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
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
@@ -0,0 +1,4 @@
Object.assign(process.env, {
'GITHUB_REPOSITORY': 'JasonEtco/waddup',
'GITHUB_ACTION': 'create-an-issue'
})

0 comments on commit 64520c0

Please sign in to comment.