-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.44 KB
/
issue.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Read Issue and Write to File
on:
issues:
types: [opened, edited]
jobs:
write_to_file:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read issue and write to file
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const issue_number = context.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const issue = await github.rest.issues.get({
owner: owner,
repo: repo,
issue_number: issue_number,
});
fs.writeFileSync('./ISSUE_CONTENT.md', issue.data.body);
- name: comment on issue
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'I have written the issue content to a file. You can see it [here](./ISSUE_CONTENT.md).'
- name: Commit and push if it changed
run: |
git config --global user.name 'Automated'
git config --global user.email 'actions@users.noreply.github.com'
git add -A
git diff --quiet && git diff --staged --quiet || git commit -m 'Updated ISSUE_CONTENT.md'
git push