Skip to content

Commit f5cf2dc

Browse files
committed
add readme.md
1 parent 82f94f5 commit f5cf2dc

File tree

2 files changed

+19
-105
lines changed

2 files changed

+19
-105
lines changed

README.md

Lines changed: 18 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,30 @@
1-
# Create a JavaScript Action
1+
# Pull Request Description Enforcer
22

3-
<p align="center">
4-
<a href="https://github.com/actions/javascript-action/actions"><img alt="javscript-action status" src="https://github.com/actions/javascript-action/workflows/units-test/badge.svg"></a>
5-
</p>
3+
github action for enforcing description on pull requests
64

7-
Use this template to bootstrap the creation of a JavaScript action.:rocket:
8-
9-
This template includes tests, linting, a validation workflow, publishing, and versioning guidance.
10-
11-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
12-
13-
## Create an action from this template
14-
15-
Click the `Use this Template` and provide the new repo details for your action
16-
17-
## Code in Main
18-
19-
Install the dependencies
20-
21-
```bash
22-
npm install
23-
```
24-
25-
Run the tests :heavy_check_mark:
26-
27-
```bash
28-
$ npm test
29-
30-
PASS ./index.test.js
31-
✓ throws invalid number (3ms)
32-
wait 500 ms (504ms)
33-
test runs (95ms)
34-
...
35-
```
36-
37-
## Change action.yml
38-
39-
The action.yml contains defines the inputs and output for your action.
40-
41-
Update the action.yml with your name, description, inputs and outputs for your action.
42-
43-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
44-
45-
## Change the Code
46-
47-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
48-
49-
```javascript
50-
const core = require('@actions/core');
51-
...
52-
53-
async function run() {
54-
try {
55-
...
56-
}
57-
catch (error) {
58-
core.setFailed(error.message);
59-
}
60-
}
61-
62-
run()
63-
```
64-
65-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
66-
67-
## Package for distribution
68-
69-
GitHub Actions will run the entry point from the action.yml. Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules.
70-
71-
Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder.
72-
73-
Run prepare
74-
75-
```bash
76-
npm run prepare
77-
```
78-
79-
Since the packaged index.js is run from the dist folder.
80-
81-
```bash
82-
git add dist
83-
```
84-
85-
## Create a release branch
5+
## Usage
866

87-
Users shouldn't consume the action from master since that would be latest code and actions can break compatibility between major versions.
7+
### Create Workflow
888

89-
Checkin to the v1 release branch
9+
Create a workflow (eg: `.github/workflows/pr-description-enforcer.yml` see [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)) to utilize the action with content:
9010

91-
```bash
92-
git checkout -b v1
93-
git commit -a -m "v1 release"
9411
```
12+
# This workflow will enforce description on pull requests.
9513
96-
```bash
97-
git push origin v1
98-
```
14+
name: 'PR Description Enforcer'
15+
on:
16+
pull_request:
17+
types: [opened, edited, reopened]
9918
100-
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.
101-
102-
Your action is now published! :rocket:
103-
104-
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
105-
106-
## Usage
19+
jobs:
20+
enforce:
21+
runs-on: ubuntu-latest
10722
108-
You can now consume the action by referencing the v1 branch
23+
steps:
24+
- uses: derkinderfietsen/pr-description-enforcer@v1
25+
with:
26+
repo-token: '${{ secrets.GITHUB_TOKEN }}'
10927
110-
```yaml
111-
uses: actions/javascript-action@v1
112-
with:
113-
milliseconds: 1000
11428
```
11529

116-
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:
30+
_Note: This grants access to the `GITHUB_TOKEN` so the action can make calls to GitHub's rest API_

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const getPrDescription = async (client) => {
4242
pull_number: prNumber
4343
});
4444

45+
// github adds \r\n on pr body
4546
return pullRequest.body.replace(/(\r\n)/g, '\n')
4647
}
4748

@@ -70,7 +71,6 @@ const getPrTemplate = async (client, paths) => {
7071
}
7172
}
7273

73-
// most @actions toolkit packages have async methods
7474
async function run() {
7575
try {
7676
const token = core.getInput("repo-token", { required: true });

0 commit comments

Comments
 (0)