Skip to content

Commit 2d4df8a

Browse files
committed
chore(ci): convert inline gh-script to file
Signed-off-by: heitorlessa <[email protected]>
1 parent 92b475b commit 2d4df8a

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

.github/scripts/save_pr_details.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = async ({github, context, core}) => {
2+
const fs = require('fs');
3+
const filename = "pr.txt";
4+
5+
try {
6+
core.debug("Payload as it comes..");
7+
core.debug(context.payload);
8+
fs.writeFileSync(`./${filename}`, JSON.stringify(context.payload));
9+
10+
return `PR successfully saved ${filename}`
11+
} catch (err) {
12+
core.setFailed("Failed to save PR details");
13+
console.error(err);
14+
}
15+
}

.github/workflows/record_pr.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ name: Record PR number
22

33
on:
44
pull_request:
5-
types: [opened, edited]
5+
types: [opened, edited, closed]
66

77
jobs:
88
build:
99
runs-on: ubuntu-latest
1010

1111
steps:
1212
- uses: actions/checkout@v3
13-
- name: Save PR number
14-
run: |
15-
mkdir -p ./pr
16-
echo ${{ github.event.number }} > ./pr/number
17-
echo "${{ github.event.pull_request.title }}" > ./pr/title
18-
echo "${{ github.event.pull_request.body }}" > ./pr/body
19-
echo "${{ github.event.pull_request.user.login }}" > ./pr/author
20-
echo "${{ github.event.action }}" > ./pr/action
13+
- name: "Extract PR details"
14+
uses: actions/github-script@v6
15+
with:
16+
script: |
17+
const script = require('.github/scripts/save_pr_details.js')
18+
await script({github, context, core})
2119
- uses: actions/upload-artifact@v3
2220
with:
2321
name: pr
24-
path: pr/
22+
path: pr.txt

0 commit comments

Comments
 (0)