|
| 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}}." |
0 commit comments