diff --git a/.github/workflows/pr-template.yml b/.github/workflows/pr.yml similarity index 67% rename from .github/workflows/pr-template.yml rename to .github/workflows/pr.yml index 5de748281d..06539107bb 100644 --- a/.github/workflows/pr-template.yml +++ b/.github/workflows/pr.yml @@ -1,9 +1,10 @@ -name: PR Template +name: PR on: pull_request_target: types: - opened + - reopened - edited - synchronize - labeled @@ -14,8 +15,95 @@ permissions: issues: write jobs: - validate: - name: Validate + label: + name: Label + runs-on: ubuntu-latest + + steps: + - name: Check changed paths + id: changes + uses: dorny/paths-filter@v3 + with: + filters: | + ci: + - ".github/workflows/*" + - "tests/*" + - "util/*" + - "package.json" + - "package-lock.json" + - "dnsconfig.js" + domain: + - "domains/*" + documentation: + - ".github/PULL_REQUEST_TEMPLATE.md" + - ".github/copilot-instructions.md" + - "README.md" + r-william: + - ".github/CODEOWNERS" + - "CODE_OF_CONDUCT.md" + - "CONTRIBUTING.md" + - "SECURITY.md" + - "TERMS_OF_SERVICE.md" + - "LICENSE" + + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + ref: ${{ github.event.repository.default_branch }} + + - name: Check trusted user + id: check-trusted + continue-on-error: true + env: + PR_AUTHOR_ID: ${{ github.event.pull_request.user.id }} + run: | + node - <<'NODE' + const trustedUsers = require("./util/trusted.json"); + + const authorId = Number(process.env.PR_AUTHOR_ID); + + if (!trustedUsers.some((u) => u.id === authorId)) { + console.log("PR author is not a trusted user."); + process.exit(1); + } + + console.log("PR author is a trusted user."); + NODE + + - name: Add labels + uses: actions/github-script@v8 + env: + CI_CHANGED: ${{ steps.changes.outputs.ci }} + DOCUMENTATION: ${{ steps.changes.outputs.documentation }} + DOMAIN_CHANGED: ${{ steps.changes.outputs.domain }} + MAINTAINER: ${{ steps.check-trusted.outcome == 'success' }} + R_WILLIAM: ${{ steps.changes.outputs.r-william }} + with: + github-token: ${{ secrets.BOT }} + script: | + const labels = []; + + if (process.env.CI_CHANGED === "true") { + labels.push("ci"); + labels.push("r: william"); + } + if (process.env.DOCUMENTATION === "true") labels.push("documentation"); + if (process.env.DOMAIN_CHANGED === "true") labels.push("domain"); + if (process.env.MAINTAINER === "true") labels.push("maintainer"); + if (process.env.R_WILLIAM === "true") labels.push("r: william"); + + const uniqueLabels = [...new Set(labels)]; + + if (uniqueLabels.length) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: uniqueLabels + }); + } + + template: + name: Template runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 diff --git a/.github/workflows/update-pr-branches.yml b/.github/workflows/update-pr-branches.yml new file mode 100644 index 0000000000..6c68c989e5 --- /dev/null +++ b/.github/workflows/update-pr-branches.yml @@ -0,0 +1,41 @@ +name: Update PR Branches + +on: + workflow_dispatch: + +jobs: + update: + name: Update + runs-on: ubuntu-latest + + steps: + - name: Update branches + uses: actions/github-script@v8 + with: + github-token: ${{ secrets.BOT }} + script: | + const prs = await github.paginate( + github.rest.pulls.list, + { + owner: context.repo.owner, + repo: context.repo.repo, + state: "open", + per_page: 100 + } + ); + + console.log(`Found ${prs.length} open PRs`); + + for (const pr of prs) { + try { + await github.rest.pulls.updateBranch({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number + }); + + console.log(`Updated #${pr.number} (${pr.head.ref})`); + } catch (error) { + console.log(`Could not update #${pr.number}: ${error.message}`); + } + } diff --git a/domains/db-projetos.adssousag.json b/domains/db-projetos.adssousag.json index 922dcdfd2e..964e2a8b88 100644 --- a/domains/db-projetos.adssousag.json +++ b/domains/db-projetos.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "p3-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/domains/kiritoapi.adssousag.json b/domains/kiritoapi.adssousag.json index de8e5bd978..964e2a8b88 100644 --- a/domains/kiritoapi.adssousag.json +++ b/domains/kiritoapi.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "kiritoapi-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/domains/kiritodb.adssousag.json b/domains/kiritodb.adssousag.json index 42a2f78e7a..964e2a8b88 100644 --- a/domains/kiritodb.adssousag.json +++ b/domains/kiritodb.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "kiritodb-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/domains/mesh-kiritoapi.adssousag.json b/domains/mesh-kiritoapi.adssousag.json index 922dcdfd2e..964e2a8b88 100644 --- a/domains/mesh-kiritoapi.adssousag.json +++ b/domains/mesh-kiritoapi.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "p3-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/domains/myst-kiritoapi.adssousag.json b/domains/myst-kiritoapi.adssousag.json index 922dcdfd2e..964e2a8b88 100644 --- a/domains/myst-kiritoapi.adssousag.json +++ b/domains/myst-kiritoapi.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "p3-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/domains/status-kiritoapi.adssousag.json b/domains/status-kiritoapi.adssousag.json index 922dcdfd2e..964e2a8b88 100644 --- a/domains/status-kiritoapi.adssousag.json +++ b/domains/status-kiritoapi.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "p3-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/domains/status-kiritodb.adssousag.json b/domains/status-kiritodb.adssousag.json index 922dcdfd2e..964e2a8b88 100644 --- a/domains/status-kiritodb.adssousag.json +++ b/domains/status-kiritodb.adssousag.json @@ -4,7 +4,7 @@ "email": "arthursantossousa05@gmail.com" }, "records": { - "CNAME": "p3-host.triniumhost.com" + "CNAME": "p-host.triniumhost.indevs.in" }, "proxied": true } diff --git a/util/check-pr-template.cjs b/util/check-pr-template.cjs index 0c691a5060..51a8b8ec23 100644 --- a/util/check-pr-template.cjs +++ b/util/check-pr-template.cjs @@ -5,10 +5,10 @@ const authorUsername = process.env.PR_AUTHOR || ""; const authorId = Number(process.env.PR_AUTHOR_ID); const labels = JSON.parse(process.env.PR_LABELS || "[]"); -const BYPASS_LABEL = "ci: bypass-template-check"; +const BYPASS_LABELS = ["ci: bypass-template-check", "maintainer"]; const isTrustedUser = trustedUsers.some((u) => u.id === authorId); -const hasBypassLabel = labels.includes(BYPASS_LABEL); +const hasBypassLabel = labels.some((l) => BYPASS_LABELS.includes(l)); if (isTrustedUser) { console.log(`PR author "${authorUsername}" is a trusted user. Skipping template validation.`); @@ -16,7 +16,7 @@ if (isTrustedUser) { } if (hasBypassLabel) { - console.log(`PR has the "${BYPASS_LABEL}" label. Skipping template validation.`); + console.log(`PR has a label which bypasses this check. Skipping template validation.`); process.exit(0); }