Skip to content

Commit 8e102c9

Browse files
merge chagnes
1 parent 34b059a commit 8e102c9

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/workflow.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
jobs:
77
update:
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write # Grant write permissions
911
steps:
1012
- name: Checkout repository
1113
uses: actions/checkout@v2
@@ -24,7 +26,6 @@ jobs:
2426
env:
2527
ISSUE_BODY: ${{ github.event.issue.body }}
2628
run: |
27-
echo "$ISSUE_BODY" > issue_body.json
2829
python update_library.py
2930
3031
- name: Commit changes
@@ -33,4 +34,29 @@ jobs:
3334
git config --global user.email "actions@github.com"
3435
git add data/library.json data/library.csv
3536
git commit -m "Update library data"
36-
git push
37+
git push origin HEAD:${{ github.ref }}
38+
- name: Close issue
39+
if: success() && github.event.issue.state == 'open'
40+
uses: peter-evans/close-issue@v2
41+
with:
42+
issue-number: ${{ github.event.issue.number }}
43+
comment: "Library updated successfully and issue closed."
44+
reason: completed
45+
- name: Handle failure
46+
if: failure()
47+
uses: actions/github-script@v6
48+
with:
49+
script: |
50+
const issue_number = context.payload.issue.number;
51+
const comment = "There was an error updating the library. Please check the logs for details.";
52+
await github.issues.createComment({
53+
...context.repo,
54+
issue_number,
55+
body: comment
56+
});
57+
await github.issues.update({
58+
...context.repo,
59+
issue_number,
60+
state: 'open'
61+
});
62+

0 commit comments

Comments
 (0)