-
-
Notifications
You must be signed in to change notification settings - Fork 6
39 lines (33 loc) · 1.26 KB
/
update-projects.yml
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
name: Process Issue
on:
issues:
types: [closed]
jobs:
process-issue:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Append issue body to projects.json
run: |
BODY=$(echo "${{ github.event.issue.body }}" | jq -sR .)
JSON_OBJECT="{\"content\": $BODY}"
if [[ -f projects.json ]]; then
# Append with newline, handling the case where file is not empty
if [[ $(jq '. | length' projects.json) -gt 0 ]]; then
jq ". += [$JSON_OBJECT]" projects.json > projects.json.tmp && mv projects.json.tmp projects.json
else
echo "[$JSON_OBJECT]" > projects.json
fi
else
# If projects.json doesn't exist, create it with the new content
echo "[$JSON_OBJECT]" > projects.json
fi
echo "" >> projects.json # Always add new line
- name: Commit and push changes
run: |
git config --global user.name 'GitHub Actions Bot'
git config --global user.email 'actions@github.com'
git add projects.json
git commit -m "Update projects.json with issue body"
git push origin projects --force