Skip to content

Commit

Permalink
Add some helpful reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Sep 22, 2024
1 parent 6095d6e commit 08b5ea5
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions .github/workflows/notify-triage.yml
Original file line number Diff line number Diff line change
@@ -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.'
21 changes: 21 additions & 0 deletions .github/workflows/reject-pr.yml
Original file line number Diff line number Diff line change
@@ -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.
65 changes: 61 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 08b5ea5

Please sign in to comment.