-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate GitHub Actions from v1 to v2 (#4)
* Migrate GitHub Actions from v1 to v2 * Add a workflow for build, lint and test * Fix comment format to see a referenced issue * Change the format of branch-prefix * Update document on how to use the action
- Loading branch information
Showing
23 changed files
with
31,523 additions
and
2,913 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ | ||
entrypoint.js | ||
index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"plugins": ["jest", "@typescript-eslint"], | ||
"extends": ["plugin:github/es6"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 9, | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"rules": { | ||
"eslint-comments/no-use": "off", | ||
"import/no-namespace": "off", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}], | ||
"@typescript-eslint/no-require-imports": "error", | ||
"@typescript-eslint/array-type": "error", | ||
"@typescript-eslint/await-thenable": "error", | ||
"@typescript-eslint/ban-ts-ignore": "error", | ||
"camelcase": "off", | ||
"@typescript-eslint/camelcase": "error", | ||
"@typescript-eslint/class-name-casing": "error", | ||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}], | ||
"@typescript-eslint/func-call-spacing": ["error", "never"], | ||
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"], | ||
"@typescript-eslint/no-array-constructor": "error", | ||
"@typescript-eslint/no-empty-interface": "error", | ||
"@typescript-eslint/no-explicit-any": "error", | ||
"@typescript-eslint/no-extraneous-class": "error", | ||
"@typescript-eslint/no-for-in-array": "error", | ||
"@typescript-eslint/no-inferrable-types": "error", | ||
"@typescript-eslint/no-misused-new": "error", | ||
"@typescript-eslint/no-namespace": "error", | ||
"@typescript-eslint/no-non-null-assertion": "warn", | ||
"@typescript-eslint/no-unnecessary-qualifier": "error", | ||
"@typescript-eslint/no-unnecessary-type-assertion": "error", | ||
"@typescript-eslint/no-useless-constructor": "error", | ||
"@typescript-eslint/no-var-requires": "error", | ||
"@typescript-eslint/prefer-for-of": "warn", | ||
"@typescript-eslint/prefer-function-type": "warn", | ||
"@typescript-eslint/prefer-includes": "error", | ||
"@typescript-eslint/prefer-string-starts-ends-with": "error", | ||
"@typescript-eslint/promise-function-async": "error", | ||
"@typescript-eslint/require-array-sort-compare": "error", | ||
"@typescript-eslint/restrict-plus-operands": "error", | ||
"semi": "off", | ||
"@typescript-eslint/semi": ["error", "never"], | ||
"@typescript-eslint/type-annotation-spacing": "error", | ||
"@typescript-eslint/unbound-method": "error" | ||
}, | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
"jest/globals": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Test | ||
on: | ||
push | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
- name: npm install, build, lint and test | ||
run: | | ||
npm install | ||
npm run all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
coverage | ||
coverage | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": false, | ||
"arrowParens": "avoid", | ||
"parser": "typescript" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,43 @@ | ||
# add-an-issue-reference-action | ||
# Add an issue reference | ||
A GitHub Action for adding a related issue reference to a pull request. | ||
|
||
## :arrow_forward: Usage | ||
A workflow adds a comment included a link for a related issue based on the branch name to a pull request when a pull request is opened. | ||
A workflow adds a comment contained a link for a related issue based on the branch name to a pull request when a pull request is opened. | ||
|
||
![](./add-an-issue-reference.png) | ||
![Adds a comment contained a link for a related issue](usage.png) | ||
|
||
Add `.github/main.workflow` with the following: | ||
### Create a workflow | ||
|
||
```hcl | ||
workflow "Add an issue reference to a pull request" { | ||
on = "pull_request" | ||
resolves = "Add an issue reference" | ||
} | ||
Add `.github/workflows/issue-reference.yml` with the following: | ||
|
||
action "Add an issue reference" { | ||
uses = "kentaro-m/add-an-issue-reference-action@master" | ||
secrets = ["GITHUB_TOKEN"] | ||
# branch name prefix | ||
args = "{\"branch\":\"issue\"}" | ||
} | ||
```yml | ||
name: 'Issue Reference' | ||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
issue-reference: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: kentaro-m/[email protected] | ||
with: | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
branch-prefix: "TICKET-" | ||
``` | ||
When you use this action, create a branch based on the pattern of the branch name (`[branch name prefix]-[issue number]`) set up on `main.workflow`. For example, if `args` is `"{\"branch\":\"issue\"}"`, create a branch like `issue-8`. | ||
### Set up required parameters | ||
Need to contain the required parameters on the workflow file. | ||
- `repo-token` A token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}` | ||
- `branch-prefix` A prefix of the branch name for finding a related issue (e.g `TICKET-`). | ||
|
||
### Add a comment contained a link for a related issue | ||
Create a branch based on the pattern of the branch name (`[branch prefix][issue number]`) set up on `.github/workflows/issue-reference.yml`. | ||
|
||
For example, if `branch-prefix` is `TICKET-`, create a branch like `TICKET-8`. | ||
|
||
When pushing your changes to the repository and creating a pull request, a workflow runs automatically. | ||
|
||
## :memo: Licence | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {getIssueNumber} from '../src/utils' | ||
|
||
describe('getIssueNumber', () => { | ||
it('Gets the issue number based on branch name', () => { | ||
const branchName = 'issue-29' | ||
const pattern = /issue-([0-9]+)/ | ||
|
||
const issueNumber = getIssueNumber(branchName, pattern) | ||
|
||
expect(issueNumber).toBe(29) | ||
}) | ||
|
||
it('Gets number 0 if the branch name is a pattern not match', () => { | ||
const branchName = 'patch1' | ||
const pattern = /issue-([0-9]+)/ | ||
|
||
const issueNumber = getIssueNumber(branchName, pattern) | ||
|
||
expect(issueNumber).toBe(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'Add an issue reference' | ||
description: 'A GitHub Action for adding a related issue reference to a pull request.' | ||
author: 'kentaro-m' | ||
inputs: | ||
branch-prefix: | ||
description: 'The prefix of branch name.' | ||
required: true | ||
repo-token: | ||
description: 'Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }}' | ||
required: true | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' | ||
branding: | ||
icon: 'image' | ||
color: 'gray-dark' |
Binary file not shown.
Oops, something went wrong.