Skip to content

Commit ee654d9

Browse files
committed
Convert action to TypeScript
1 parent cbfc30b commit ee654d9

22 files changed

Lines changed: 47406 additions & 441 deletions

Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# First Interaction
22

3-
An action for filtering pull requests and issues from first-time contributors.
3+
[![Super-Linter](https://github.com/actions/first-interaction/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
4+
![CI](https://github.com/actions/first-interaction/actions/workflows/ci.yml/badge.svg)
5+
[![Check dist/](https://github.com/actions/first-interaction/actions/workflows/check-dist.yml/badge.svg)](https://github.com/actions/first-interaction/actions/workflows/check-dist.yml)
6+
[![CodeQL](https://github.com/actions/first-interaction/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/actions/first-interaction/actions/workflows/codeql-analysis.yml)
7+
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)
8+
9+
An action for filtering pull requests (PRs) and issues from first-time
10+
contributors.
11+
12+
When a first-time contributor opens a PR or issue, this action will add a
13+
comment to the PR or issue with a message of your choice. This action is useful
14+
for welcoming first-time contributors to your project and providing them with
15+
information about how to contribute effectively.
416

517
## Usage
618

@@ -9,23 +21,32 @@ See [action.yml](action.yml)
921
```yaml
1022
name: Greetings
1123

12-
on: [pull_request, issues]
24+
on:
25+
pull_request:
26+
types:
27+
- opened
28+
issues:
29+
types:
30+
- opened
31+
32+
permissions:
33+
issues: write
34+
pull-requests: write
1335

1436
jobs:
1537
greeting:
38+
name: Greet First-Time Contributors
1639
runs-on: ubuntu-latest
40+
1741
steps:
18-
- uses: actions/first-interaction@v1
19-
with:
20-
repo-token: ${{ secrets.GITHUB_TOKEN }}
21-
issue-message: |
22-
# Message with markdown.
23-
This is the message that will be displayed on users' first issue.
24-
pr-message: |
25-
Message that will be displayed on users' first pr.
26-
Look, a `code block` for markdown.
27-
```
42+
- uses: actions/first-interaction@vX.Y.Z # Set this to the latest release
43+
with:
44+
issue-message: |
45+
# Issue Message with Markdown
2846
29-
## License
47+
This is the message that will be displayed!
48+
pr-message: |
49+
# PR Message with Markdown
3050
31-
The scripts and documentation in this project are released under the [MIT License](LICENSE)
51+
This is the message that will be displayed!
52+
```

__fixtures__/@actions/core.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type * as core from '@actions/core'
2+
import { jest } from '@jest/globals'
3+
4+
export const debug = jest.fn<typeof core.debug>()
5+
export const error = jest.fn<typeof core.error>()
6+
export const info = jest.fn<typeof core.info>()
7+
export const getInput = jest.fn<typeof core.getInput>()
8+
export const setOutput = jest.fn<typeof core.setOutput>()
9+
export const setFailed = jest.fn<typeof core.setFailed>()
10+
export const warning = jest.fn<typeof core.warning>()

__fixtures__/@actions/github.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as octokit from '../@octokit/rest.js'
2+
3+
export const getOctokit = () => octokit
4+
5+
export const context = {
6+
eventName: 'pull_request',
7+
issue: {
8+
number: 10
9+
},
10+
payload: {
11+
number: 10,
12+
issue: {
13+
number: 10
14+
},
15+
pull_request: {
16+
number: 10
17+
},
18+
sender: {
19+
login: 'mona'
20+
}
21+
},
22+
action: 'opened',
23+
repo: {
24+
owner: 'actions',
25+
repo: 'first-interaction'
26+
}
27+
}

__fixtures__/@octokit/rest.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { jest } from '@jest/globals'
2+
import { Endpoints } from '@octokit/types'
3+
4+
export const graphql = jest.fn()
5+
export const paginate = jest.fn()
6+
export const rest = {
7+
issues: {
8+
createComment:
9+
jest.fn<
10+
() => Endpoints['POST /repos/{owner}/{repo}/issues/{issue_number}/comments']['response']
11+
>(),
12+
listForRepo:
13+
jest.fn<() => Endpoints['GET /repos/{owner}/{repo}/issues']['response']>()
14+
},
15+
pulls: {
16+
list: jest.fn<
17+
() => Endpoints['GET /repos/{owner}/{repo}/pulls']['response']
18+
>()
19+
}
20+
}

0 commit comments

Comments
 (0)