Skip to content

Commit b17d17d

Browse files
authored
Merge pull request #114 from NathanielRN/repo-owner-and-name
Support repo.repo and repo.owner as template variables
2 parents 2fa1fa4 + c0073b8 commit b17d17d

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ labels: bug, enhancement
3131
Someone just pushed, oh no! Here's who did it: {{ payload.sender.login }}.
3232
```
3333

34-
You'll notice that the above example has some `{{ mustache }}` variables. Your issue templates have access to everything about the event that triggered the action. [Here is a list of all of the available template variables](https://github.com/JasonEtco/actions-toolkit#toolscontext). You can also use environment variables:
34+
You'll notice that the above example has some `{{ mustache }}` variables. Your issue templates have access to several things about the event that triggered the action. Besides `issue` and `pullRequest`, you have access to all the template variables [on this list](https://github.com/JasonEtco/actions-toolkit#toolscontext). You can also use environment variables:
3535

3636
```yaml
3737
- uses: JasonEtco/create-an-issue@v2

src/action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export async function createAnIssue (tools: Toolkit) {
1515

1616
const templateVariables = {
1717
...tools.context,
18+
repo: tools.context.repo,
1819
env: process.env,
1920
date: Date.now()
2021
}

tests/__snapshots__/index.test.ts.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,26 @@ Array [
164164
]
165165
`;
166166

167+
exports[`create-an-issue creates a new issue with the context.repo template variables 1`] = `
168+
Object {
169+
"assignees": Array [],
170+
"body": "Are you looking for results on our gh-pages branch?
171+
172+
Just click this link! https://JasonEtco.github.io/waddup/path/to/my/pageindex.html
173+
",
174+
"labels": Array [],
175+
"title": "This Issue has a generalizable GitHub Pages Link",
176+
}
177+
`;
178+
179+
exports[`create-an-issue creates a new issue with the context.repo template variables 2`] = `
180+
Array [
181+
Array [
182+
"Created issue This Issue has a generalizable GitHub Pages Link#1: www",
183+
],
184+
]
185+
`;
186+
167187
exports[`create-an-issue logs a helpful error if creating an issue throws an error 1`] = `
168188
Array [
169189
Array [
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: This Issue has a generalizable GitHub Pages Link
3+
---
4+
Are you looking for results on our gh-pages branch?
5+
6+
Just click this link! https://{{ repo.owner }}.github.io/{{ repo.repo }}/path/to/my/pageindex.html

tests/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ describe('create-an-issue', () => {
8080
expect((tools.log.success as any).mock.calls).toMatchSnapshot()
8181
})
8282

83+
it('creates a new issue with the context.repo template variables', async () => {
84+
process.env.INPUT_FILENAME = '.github/context-repo-template.md'
85+
await createAnIssue(tools)
86+
expect(params).toMatchSnapshot()
87+
expect(tools.log.success).toHaveBeenCalled()
88+
expect((tools.log.success as any).mock.calls).toMatchSnapshot()
89+
})
90+
8391
it('creates a new issue with assignees, labels and a milestone', async () => {
8492
process.env.INPUT_FILENAME = '.github/kitchen-sink.md'
8593
await createAnIssue(tools)

0 commit comments

Comments
 (0)