Add GitHub actions to make reviewing of extensions easier (thanks Art… · GDevelopApp/GDevelop-extensions@68642a1 · GitHub
Skip to content

Commit 68642a1

Browse files
authored
Add GitHub actions to make reviewing of extensions easier (thanks Arthuro555!) (#235)
1 parent 8006daa commit 68642a1

6 files changed

Lines changed: 225 additions & 24 deletions

File tree

Lines changed: 16 additions & 0 deletions

‎.github/workflows/auto-pr.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: GDevelop Extensions Issues to PR convertion
2+
on:
3+
issues:
4+
types: [opened, labeled]
5+
6+
jobs:
7+
generate-pr:
8+
# Only run it on extensions submissions (tag is ensured via the new issue form)
9+
if: ${{ contains(github.event.issue.labels.*.name, '✨ New extension') || contains(github.event.issue.labels.*.name, '🔄 Extension update') }}
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Download extension
16+
env:
17+
BODY: ${{ github.event.issue.body }}
18+
run: |
19+
curl -L $(echo $BODY | grep -ioEh 'https?://\S+.zip' -m2 | tail -n1) -o /tmp/ext.zip
20+
unzip -o /tmp/ext.zip -d ./Extensions
21+
22+
- name: Create Pull Request
23+
id: cpr
24+
uses: peter-evans/create-pull-request@v3
25+
with:
26+
commit-message: 'Automated Extension submission for issue #${{ github.event.issue.number }}'
27+
committer: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
28+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
29+
branch: extension/${{ github.actor }}/${{ github.event.issue.number }}
30+
delete-branch: true
31+
title: '[Auto PR] ${{ github.event.issue.title }}'
32+
body: ${{ github.event.issue.body }}
33+
labels: ✨ New extension
34+
35+
- name: Add card to pending review
36+
uses: peter-evans/create-or-update-project-card@v1
37+
with:
38+
project-name: Extensions review
39+
column-name: Needs review
40+
issue-number: ${{ steps.cpr.outputs.pull-request-number }}
41+
42+
- name: Close and comment on issue
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: |
46+
gh issue close ${{ github.event.issue.number }}
47+
gh issue comment ${{ github.event.issue.number }} --body "Hi @${{ github.actor }}! 👋 This submission has been moved to a PR as part of our submission pipeline. [Please continue the submission process on this page](${{ steps.cpr.outputs.pull-request-url }}). Thanks!"

‎.github/workflows/auto-rebuild.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: GDevelop PR automatic rebuild of the extensions database
2+
on:
3+
pull_request:
4+
types: [opened,synchronize]
5+
jobs:
6+
rebuild-database:
7+
# Only run it on extensions submissions (tag is ensured via the new issue form)
8+
if: ${{ contains(github.event.pull_request.labels.*.name, '✨ New extension') || contains(github.event.pull_request.labels.*.name, '🔄 Extension update') }}
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Rebuild the database
14+
run: |
15+
npm i
16+
echo 'BUILD_LOGS<<EOF' >> $GITHUB_ENV
17+
node scripts/generate-extensions-registry.js --disable-exit-code >> $GITHUB_ENV
18+
echo 'EOF' >> $GITHUB_ENV
19+
echo "CHANGED="$(git diff --name-only extensions-registry.json) >> $GITHUB_ENV
20+
21+
- name: Commit and push if changed
22+
if: ${{ contains(env.CHANGED, 'extensions-registry') }}
23+
run: |
24+
git config --global user.name '${{ github.actor }}'
25+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
26+
git add extensions-registry.json
27+
git commit -m "Regenerated extension registery"
28+
git push
29+
30+
- name: Notify build errors
31+
if: ${{ !contains(env.BUILD_LOGS, 'successfully updated') }}
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
gh pr comment ${{ github.event.pull_request.number }} --body "❗ Errors were detected in this submission!
36+
37+
\`\`\`${{ env.BUILD_LOGS }}
38+
\`\`\`"

‎.github/workflows/commands.yml‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: GDevelop Extensions PR commands
2+
on: issue_comment
3+
jobs:
4+
rebase:
5+
runs-on: ubuntu-latest
6+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '!rebase') }}
7+
steps:
8+
- uses: xt0rted/pull-request-comment-branch@v1
9+
id: comment-branch
10+
11+
- uses: actions/checkout@v2
12+
with:
13+
ref: ${{ steps.comment-branch.outputs.head_ref }}
14+
fetch-depth: 0
15+
16+
- name: Set committer
17+
run: |
18+
git config --global user.name '${{ github.actor }}'
19+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
20+
21+
- name: Merge new commits from main
22+
run: git merge -X theirs origin/main -m "Rebase from main"
23+
24+
- name: Rebuild the database
25+
run: |
26+
npm i
27+
echo 'BUILD_LOGS<<EOF' >> $GITHUB_ENV
28+
node scripts/generate-extensions-registry.js --disable-exit-code >> $GITHUB_ENV
29+
echo 'EOF' >> $GITHUB_ENV
30+
31+
- name: Commit and push
32+
if: ${{ contains(env.BUILD_LOGS, 'successfully updated') }}
33+
run: |
34+
git add extensions-registry.json
35+
git commit --amend --no-edit
36+
git push
37+
38+
- name: Notify success
39+
if: ${{ contains(env.BUILD_LOGS, 'successfully updated') }}
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: gh pr comment ${{ github.event.issue.number }} --body "✅ Successfully rebased from main!"
43+
44+
- name: Notify error
45+
if: ${{ !contains(env.BUILD_LOGS, 'successfully updated') }}
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
gh pr comment ${{ github.event.issue.number }} --body "❗ A build error occured while rebasing!
50+
51+
\`\`\`${{ env.BUILD_LOGS }}
52+
\`\`\`"
53+
54+
- name: Notify any error
55+
if: ${{ failure() }}
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
gh pr comment ${{ github.event.issue.number }} --body "❗ An internal error has occured! See logs at https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}."
60+
61+
update:
62+
runs-on: ubuntu-latest
63+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '!update') }}
64+
steps:
65+
- uses: xt0rted/pull-request-comment-branch@v1
66+
id: comment-branch
67+
68+
- uses: actions/checkout@v2
69+
with:
70+
ref: ${{ steps.comment-branch.outputs.head_ref }}
71+
72+
- name: Download extension
73+
env:
74+
BODY: ${{ github.event.comment.body }}
75+
run: |
76+
curl -L $(echo $BODY | grep -ioEh 'https?://\S+.zip' -m1) -o /tmp/ext.zip
77+
unzip -o /tmp/ext.zip -d ./Extensions
78+
79+
- name: Rebuild the database
80+
id: build
81+
run: |
82+
npm i
83+
echo 'BUILD_LOGS<<EOF' >> $GITHUB_ENV
84+
node scripts/generate-extensions-registry.js --disable-exit-code >> $GITHUB_ENV
85+
echo 'EOF' >> $GITHUB_ENV
86+
87+
- name: Commit and push
88+
if: ${{ contains(env.BUILD_LOGS, 'successfully updated') }}
89+
run: |
90+
git config --global user.name '${{ github.actor }}'
91+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
92+
git add extensions-registry.json Extensions
93+
git commit -m "Updated extension"
94+
git push
95+
96+
- name: Notify success
97+
if: ${{ contains(env.BUILD_LOGS, 'successfully updated') }}
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
run: gh pr comment ${{ github.event.issue.number }} --body "✅ Successfully updated the extension!"
101+
102+
- name: Notify build error
103+
if: ${{ !contains(env.BUILD_LOGS, 'successfully updated') }}
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
run: |
107+
gh pr comment ${{ github.event.issue.number }} --body "❗ A build error occured while processing the extension update!
108+
109+
\`\`\`${{ env.BUILD_LOGS }}
110+
\`\`\`"
111+
112+
- name: Notify any error
113+
if: ${{ failure() }}
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
run: |
117+
gh pr comment ${{ github.event.issue.number }} --body "❗ An internal error has occured! See logs at https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}."

‎.github/workflows/issues.yml‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎scripts/generate-extensions-registry.js‎

Lines changed: 7 additions & 4 deletions

0 commit comments

Comments
 (0)