From 97024acef14ddb48f39dee78fe04f99559440a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Gonzalo=20Artur=20de=20la=20Villarmois?= Date: Sun, 29 Mar 2026 19:46:34 +1300 Subject: [PATCH] Add PR templates, CI workflows, and release drafter config files --- .github/pull_request_template.md | 27 ++++++++++++++ .github/release-drafter.yml | 54 +++++++++++++++++++++++++++ .github/workflows/pr-commits.yml | 43 +++++++++++++++++++++ .github/workflows/release-drafter.yml | 20 ++++++++++ .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 38 +++++++++++++++++++ 6 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 .github/pull_request_template.md create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/pr-commits.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..0c5b19a --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,27 @@ +## What does this PR do? + + + +## Commits + + + +## Type of change + + + +- [ ] ๐Ÿš€ Feature / Enhancement (`feature`, `enhancement`) +- [ ] ๐Ÿ› Bug Fix (`bug`, `fix`) +- [ ] ๐Ÿงช Tests (`test`) +- [ ] ๐Ÿงน Maintenance / Chore (`chore`, `dependencies`) +- [ ] ๐Ÿ“– Documentation (`docs`) +- [ ] ๐Ÿ’ฅ Breaking Change (`breaking`) + +## How to test + + + +## Checklist + +- [ ] Tests pass (`php artisan test`) +- [ ] Code style passes (`./vendor/bin/pint --test`) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..2b9ac2d --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,54 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' + +categories: + - title: '๐Ÿš€ Features' + labels: + - 'feature' + - 'enhancement' + - title: '๐Ÿ› Bug Fixes' + labels: + - 'bug' + - 'fix' + - title: '๐Ÿงช Tests' + labels: + - 'test' + - 'tests' + - title: '๐Ÿงน Maintenance' + labels: + - 'chore' + - 'maintenance' + - 'dependencies' + - title: '๐Ÿ“– Documentation' + labels: + - 'docs' + - 'documentation' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' + +version-resolver: + major: + labels: + - 'breaking' + minor: + labels: + - 'feature' + - 'enhancement' + patch: + labels: + - 'bug' + - 'fix' + - 'chore' + - 'maintenance' + - 'docs' + - 'documentation' + - 'test' + - 'tests' + - 'dependencies' + default: patch + +template: | + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION diff --git a/.github/workflows/pr-commits.yml b/.github/workflows/pr-commits.yml new file mode 100644 index 0000000..52b687f --- /dev/null +++ b/.github/workflows/pr-commits.yml @@ -0,0 +1,43 @@ +name: Populate PR commits + +on: + pull_request: + types: [opened, synchronize] + +jobs: + update-body: + name: Inject commit list into PR body + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - uses: actions/github-script@v7 + with: + script: | + const { data: commits } = await github.rest.pulls.listCommits({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + + const commitLines = commits + .map(c => `- ${c.commit.message.split('\n')[0]} (${c.sha.slice(0, 7)})`) + .join('\n'); + + const currentBody = context.payload.pull_request.body ?? ''; + + // Replace everything between the Commits header and the next ## header + const updated = currentBody.replace( + /(## Commits\n)[\s\S]*?(\n## )/, + `$1\n${commitLines}\n$2` + ); + + if (updated === currentBody) return; + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + body: updated, + }); diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..49cf7ad --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,20 @@ +name: Release Drafter + +on: + push: + branches: [main] + pull_request: + types: [opened, reopened, synchronize] + +jobs: + draft: + name: Draft next release notes + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: read + + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1eac02..134835c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,7 +87,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name | lower }} + images: ${{ secrets.DOCKERHUB_USERNAME }}/sgs tags: | type=semver,pattern={{version}} type=raw,value=latest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b234296..349817c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -60,3 +60,41 @@ jobs: - name: Run Pint working-directory: www run: ./vendor/bin/pint --test + + update-checklist: + name: Update PR checklist + runs-on: ubuntu-latest + if: always() && github.event_name == 'pull_request' + needs: [test, lint] + permissions: + pull-requests: write + + steps: + - uses: actions/github-script@v7 + with: + script: | + const testsPass = '${{ needs.test.result }}' === 'success'; + const lintPass = '${{ needs.lint.result }}' === 'success'; + + const check = (pass) => pass ? 'x' : ' '; + + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + + const body = (pr.body ?? '').replace( + /- \[[ x]\] Tests pass \(`php artisan test`\)/, + `- [${check(testsPass)}] Tests pass (\`php artisan test\`)` + ).replace( + /- \[[ x]\] Code style passes \(`\.\/vendor\/bin\/pint --test`\)/, + `- [${check(lintPass)}] Code style passes (\`./vendor/bin/pint --test\`)` + ); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + body, + });