From 08b5ea56d98e43f407925db1af1daa24539d5213 Mon Sep 17 00:00:00 2001 From: Claudia Meadows Date: Sun, 22 Sep 2024 14:10:31 -0700 Subject: [PATCH] Add some helpful reusable workflows --- .editorconfig | 2 +- .github/workflows/notify-triage.yml | 17 ++++++++ .github/workflows/reject-pr.yml | 21 ++++++++++ README.md | 65 +++++++++++++++++++++++++++-- 4 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/notify-triage.yml create mode 100644 .github/workflows/reject-pr.yml diff --git a/.editorconfig b/.editorconfig index 93a6ee2..ac4d385 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,6 @@ trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf -[{package.json,*.yml}] +[{package.json,*.yml,*.md}] indent_style = space indent_size = 2 diff --git a/.github/workflows/notify-triage.yml b/.github/workflows/notify-triage.yml new file mode 100644 index 0000000..fb31c64 --- /dev/null +++ b/.github/workflows/notify-triage.yml @@ -0,0 +1,17 @@ +name: Ping triage + +on: + workflow_call: + +env: + ISSUE_URL: ${{ github.event.issue.url }} + GH_TOKEN_SECRET: ${{ github.token }} + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - run: | + export GITHUB_TOKEN="$GH_TOKEN_SECRET" + gh issue edit "$ISSUE_URL" --add-project 'Triage/bugs' && + gh issue comment "$ISSUE_URL" --body '@MithrilJS/triage Please take a look.' diff --git a/.github/workflows/reject-pr.yml b/.github/workflows/reject-pr.yml new file mode 100644 index 0000000..3eec205 --- /dev/null +++ b/.github/workflows/reject-pr.yml @@ -0,0 +1,21 @@ +name: Reject PR + +on: + workflow_call: + inputs: + correct_branch: + type: string + required: true + +jobs: + post: + runs-on: ubuntu-latest + steps: + - run: | + export GITHUB_TOKEN="$GH_TOKEN_SECRET" + gh pr close "$PR_URL" --comment "$MESSAGE" --reason 'not planned' && + gh pr lock "$PR_URL" --reason 'resolved' + env: + GITHUB_TOKEN: ${{ github.token }} + PR_URL: ${{ github.event.issue.url }} + MESSAGE: Hey @${{ github.actor }}, this pull request should be directed towards `${{ inputs.correct_branch }}`. Please file a new pull request targeting that branch instead. diff --git a/README.md b/README.md index 2594eba..d63e670 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ **⚠⚠⚠ Warning: this repo is under construction. ⚠⚠⚠** -# MithrilJS global deploy scripts +# MithrilJS shared infra workflows and scripts -This handles all deploy processes and centralizes all the permissions. +This handles all deploy processes and centralizes all the permissions. It also includes some utility scripts -> Admins should use [the runbook](./RUNBOOK.md) to know how to do various things. +> Admins should consult [the runbook](./RUNBOOK.md) as well. -## Usage +- [Deploy](#deploy) +- [Block a PR with a comment](#block-a-pr-with-a-comment) +- [Notify triage](#notify-triage) +- [License](#license) + +## Deploy It's a multi-step process. @@ -35,6 +40,58 @@ It's a multi-step process. root_dir: ${{ github.workspace }}/path/to/package ``` +## Block a PR with a comment + +Usage is pretty simple. Suppose development is occurring on `main` and the PR is to the special branch `release`. You can use this workflow to handle it easily. + +```yml +name: Deny pushing to `release` +on: + pull_request: + types: [opened] + branches: [release] +permissions: + issues: write +jobs: + reject: + uses: MithrilJS/infra/.github/workflows/reject-pr.yml@main +``` + +If the right branch isn't `main`, you can specify it explicitly. Suppose it's `next` instead. It's still just as easy. + +```yml +name: Deny pushing to `release` +on: + pull_request: + types: [opened] + branches: [release] +permissions: + issues: write +jobs: + reject: + uses: MithrilJS/infra/.github/workflows/reject-pr.yml@main + with: + correct_branch: next +``` + +## Notify triage + +Usage is extremely simple. This also implicitly adds the issue to [our tracking project](https://github.com/orgs/MithrilJS/projects/2) for triage. + +```yml +name: Notify triage on issue create +on: + issues: + types: [opened] + pull_request: + types: [opened] +permissions: + issues: write +jobs: + reject: + uses: MithrilJS/infra/.github/workflows/notify-triage.yml@main +``` + ## License Copyright 2024 Mithril.js Contributors