-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (96 loc) · 3.97 KB
/
issue.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Add entry new
on:
issues:
types: [opened, edited]
# Stolen from geodes indexer lol
jobs:
issue_created:
name: Issue test
if: (!github.event.issue.pull_request && github.event.issue.state == 'open')
runs-on: ubuntu-latest
steps:
- name: Checkout Indexer
uses: actions/checkout@v4
with:
path: code
- name: Checkout Index
uses: actions/checkout@v4
with:
repository: clicksounds/geode-clicksound
path: index
- name: Verify User
id: verify_user
shell: bash
run: |
echo result=`python3 code/.github/verify.py index $ISSUE_AUTHOR` >> $GITHUB_OUTPUT
env:
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
- name: Add Entry
id: add_entry
shell: bash
run: |
echo has_issues=NO >> $GITHUB_OUTPUT
set +e
python3 code/.github/issue.py index $ISSUE_AUTHOR > result.txt 2> err.txt
RESULT=$?
set -e
echo "output is"
cat result.txt
echo "any silly errors?"
if [ -f silly_log.txt ]; then
cat silly_log.txt
fi
EOF=$(openssl rand -hex 8)
{
echo "issue_output<<$EOF"
cat result.txt
echo "$EOF"
} >> "$GITHUB_OUTPUT"
{
echo "issue_err<<$EOF"
cat err.txt
echo "$EOF"
} >> "$GITHUB_OUTPUT"
if [ $RESULT -eq 0 ]; then
echo push_entry=YES >> $GITHUB_OUTPUT
else
echo push_entry=NO >> $GITHUB_OUTPUT
fi
env:
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
COMMENT_AUTHOR: ${{ github.event.issue.user.login }}
ISSUE_BODY: ${{ github.event.issue.body }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
VERIFY_USER_RESULT: ${{ steps.verify_user.outputs.result }}
- name: Push to index
shell: bash
if: steps.add_entry.outputs.push_entry == 'YES' && steps.verify_user.outputs.result == 'YES' && steps.add_entry.outputs.has_issues == 'NO'
working-directory: ${{ github.workspace }}/index
run: |
git config --local user.email "${{ secrets.GEODE_BOT_EMAIL }}"
git config --local user.name "GeodeBot"
git add -A
git commit -m "Update from $ISSUE_AUTHOR - ${{ steps.add_entry.outputs.mod_id }}"
git remote set-url origin "https://GeodeBot:${{ secrets.GEODE_BOT_PUSH_BIN_TOKEN }}@github.com/geode-sdk/mods.git"
git push -u origin main
env:
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
- name: Close because invalid
if: steps.add_entry.outputs.issue_err != ''
run: gh issue close ${{ github.event.issue.number }} --comment "$BODY" -R "${{ github.repository }}" --reason "not planned"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: "```\n${{ steps.add_entry.outputs.issue_err }}\n```"
- name: Close because verified and valid
if: steps.verify_user.outputs.result == 'YES' && steps.add_entry.outputs.push_entry == 'YES' && steps.add_entry.outputs.has_issues == 'NO'
run: gh issue close ${{ github.event.issue.number }} --comment "$BODY" -R "${{ github.repository }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: ${{ steps.add_entry.outputs.issue_output }}
- name: Comment waiting for staff
uses: peter-evans/create-or-update-comment@v4
if: (steps.verify_user.outputs.result == 'NO' || steps.add_entry.outputs.has_issues == 'YES') && steps.add_entry.outputs.push_entry == 'YES'
with:
issue-number: ${{ github.event.issue.number }}
body: |
Waiting for a person who can approve to comment "!accept" to accept the entry.