Reusable GitHub Actions workflows.
The auto-merge
reusable action is located in .github/workflows/auto-merge.yml
. To use it you will need a Personal Access Token with the following scopes:
repo
for private repositoriespublic_repo
for public repositories
NOTE: This action will auto merge only those pull requests that were opened by Dependabot.
In the repository that will call this action, you need to define a secret named GH_TOKEN
with the value of your Personal Access Token.
This reusable action depends on the following actions:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the workflow from running on forks of mdn/workflows
.
- This
input
is required
The action has the following optional inputs:
Automatically approve pull-requests.
- This
input
is optional with a default oftrue
.
The command to pass to Dependabot.
- This
input
is optional with a default ofsquash and merge
.
The version comparison target. One off major, minor, or patch.
- This
input
is optional with a default ofminor
.
In the repository that will call this action, you will need to add a .github/workflows/auto-merge.yml
file with the following content:
name: "auto-merge"
on: [pull_request_target]
jobs:
auto-merge:
uses: mdn/workflows/.github/workflows/auto-merge.yml@main
with:
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
name: "auto-merge"
on: [pull_request_target]
jobs:
auto-merge:
uses: mdn/workflows/.github/workflows/auto-merge.yml@main
with:
auto-approve: false
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
The pr-rebase-needed
reusable action is located in .github/workflows/pr-rebase-needed.yml
.
This reusable action depends on the following actions:
The action has the following inputs:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required.
If your repository uses a label named anything other than rebase needed π§
(for example, the repository may use merge conflicts
), you can set the label here.
- This
input
is optional with a default ofrebase needed :construction:
When a rebase is needed, the action will write a comment on the pull request to let the PR author know there are merge conflicts. This can be changed to whatever the repository desires, or left blank if no comment should be added.
- This
input
is optional with a default ofThis pull request has merge conflicts that must be resolved before it can be merged.
This action requires the following secrets to be passed by the caller. These need to be set as environmental secrets using the calling repositories settings.
Personal access token passed from the caller workflow. Read the documentation on creating a PA token.
In the repository that will call this action, you will need to add a .github/workflows/pr-rebase-needed.yml
file with the following content:
name: pr-rebase-needed
on:
push:
pull_request_target:
types: [synchronize]
jobs:
pr-rebase-needed:
uses: mdn/workflows/.github/workflows/pr-rebase-needed.yml@main
with:
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
name: pr-rebase-needed
on:
push:
pull_request_target:
types: [synchronize]
jobs:
pr-rebase-needed:
uses: mdn/workflows/.github/workflows/pr-rebase-needed.yml@main
with:
comment: "This pull requests has merge conflicts that needs to be resolved before being merged. Thank you."
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
The idle
reusable action is located in .github/workflows/idle.yml
.
NOTE: We currently use this action to label issues only. We do not automatically close issues or pull requests using this action.
This reusable action depends on the following actions:
The action has the following inputs:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required.
If set to a non-negative number, issues and pull requests with the idle label will automatically be closed after the set number of days.
- This
input
is optional with a default of -1
If your repository uses a label named anything other than π idle
(for example, the repository may want to use use stale
), you can set the label here.
- This
input
is optional with a default ofπ idle
The number of days before the issue or pull request is considered idle and the label and/or comment is applied.
- This
input
is optional with a default of 37
In the repository that will call this action, you will need to add a .github/workflows/mark-as-idle.yml
file with the following content:
name: "Label Idle Issues"
on:
push:
pull_request_target:
types: [synchronize]
jobs:
mark-as-idle:
uses: mdn/workflows/.github/workflows/mark-as-idle.yml@main
with:
target-repo: "mdn/workflows"
name: "Label Idle Issues"
on:
push:
pull_request_target:
types: [synchronize]
jobs:
mark-as-idle:
uses: mdn/workflows/.github/workflows/mark-as-idle.yml@main
with:
label: "stale"
target-repo: ${{ input.target_repo }}
The lock-closed
GitHub Action automatically locks issues and PRs that have been closed for more than a year.
It is intended to reduce "necrobumping" (the addition of comments, including spam, to old/closed issues).
This reusable action depends on the following actions:
The action has the following inputs:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required.
The number of days before an issue is considered inactive.
- This
input
is optional with a default of 365
In the repository that will call this action, you will need to add a .github/workflows/lock-closed.yml
file with the following content:
name: "Lock inactive issues and pull requests"
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
lock-closed:
uses: mdn/workflows/.github/workflows/lock-closed.yml@main
with:
target-repo: "mdn/workflows"
name: "Lock inactive issues and pull requests"
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
lock-closed:
uses: mdn/workflows/.github/workflows/lock-closed.yml@main
with:
issue-inactive-days: 42
target-repo: "mdn/workflows"
The publish-release
GitHub Action automates publication of a new release on GitHub, updates the changelog and also publishes to the NPM registry.
NOTE: For the
release-please
workflow to work effectively, you need to follow the conventional commits conventions as detailed here. You can also find additional documentation on the GitHub Actions README.
This reusable action depends on the following actions:
The action has the following inputs:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required.
This is can be one of the release types as detailed in the release please docs.
- This
input
is optional with a default ofnode
The version of Node.js to use for the release. This action supports all active and maintenance releases of Node.js.
- This
input
is optional with a default of12
Whether to publish the package to the NPM registry.
- This
input
is optional with a default oftrue
Arguments to pass to the npm publish
command. This is ignored if npm-publish
is set to false
.
- This
input
is optional with a default of an empty string
The registry to publish to.
- This
input
is optional with a default ofhttps://registry.npmjs.org
This action requires the following secrets to be passed by the caller. Both of these need to be set as environmental secrets using the calling repositories settings.
Personal access token passed from the caller workflow. Read the documentation on creating a PA token.
Authentication token for the NPM registry. Read the documentation for details on creating a token.
NOTE: When skipping NPM publishing, this token is not required.
In the repository that will call this action, you will need to add a .github/workflows/publish-release.yml
file with the following content:
name: publish-release
on:
push:
branches:
- main
jobs:
publish-release:
uses: mdn/workflows/.github/workflows/publish-release.yml@main
with:
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
name: publish-release
on:
push:
branches:
- main
jobs:
publish-release:
uses: mdn/workflows/.github/workflows/publish-release.yml@main
with:
release-type: python
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
name: publish-release
on:
push:
branches:
- main
jobs:
publish-release:
uses: mdn/workflows/.github/workflows/publish-release.yml@main
with:
npm-publish: false
target-repo: "mdn/workflows"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
The new-issues
reusable action is located in .github/workflows/new-issues.yml
.
This reusable action depends on the following actions:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required.
The action has the following inputs:
Labels to add as a comma separated list.
- This
input
is optional with a default ofneeds-triage
.
In the repository that will call this action, you will need to add a .github/workflows/new-issues.yml
file with the following content:
name: "Mark new issues with specified label(s)"
on:
issues:
types:
- reopened
- opened
jobs:
label-new-issues:
uses: mdn/workflows/.github/workflows/new-issues.yml@main
with:
target-repo: "mdn/workflows"
name: "Mark new issues with specified label(s)"
on:
issues:
types:
- reopened
- opened
jobs:
label-new-issues:
uses: mdn/workflows/.github/workflows/new-issues.yml@main
with:
add-labels: "triage, bug"
target-repo: "mdn/workflows"
The set-default-labels
reusable action is located in .github/workflows/set-default-labels.yml
.
This reusable action depends on the following actions:
The action has the following inputs:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required. (type:string
)
This is an optional boolean
input that is false
by default. If set to true
, the action will delete any existing labels that are not listed in the JSON file mentioned previously.
In the repository that will call this action, you will need to create the following file: .github/labels.json
. The content of the file can be something like the following:
[
{
"name": "bug",
"color": "#d73a4a",
"description": "something isnβt working"
},
{
"name": "chore",
"color": "#fef2c0",
"description": "keeping the lights on"
}
]
You can find more details about the above on the issue-label-manager-action documentation. The next item you need to create in the repository that will call this action, is a workflow file. You can name the file .github/workflows/set-default-labels.yml
and add the following content:
name: set-default-labels
on: [workflow_dispatch]
jobs:
set-default-labels:
uses: mdn/workflows/.github/workflows/set-default-labels.yml@main
with:
target-repo: "mdn/workflows"
name: set-default-labels
on: [workflow_dispatch]
jobs:
set-default-labels:
uses: mdn/workflows/.github/workflows/set-default-labels.yml@main
with:
target-repo: "mdn/workflows"
should-delete-labels: true
Because of the nature of this action, it must be run manually. You can learn more about manually running actions on GitHub.
The json-lint
reusable action is located in .github/workflows/json-lint.yml
. This workflow will use eslint
to lint JSON files in the target repository. You can use the paths
filter to only trigger this workflow for specific files or file patterns. More on this in the usage section.
This reusable action depends on the following actions:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required
The node version to setup and use.
- This
input
is optional, with a default of 16.
Which package manager cache to use.
- This
input
is optional, with a default of yarn.
name: json-lint
on:
pull_request:
branches:
- main
paths:
- '*.json'
- .github/workflows/json-lint.yml
jobs:
json-lint:
uses: mdn/workflows/.github/workflows/json-lint.yml@main
with:
target-repo: "mdn/workflows"
Above you can see how the paths
filter is being used to specify specific files and file patterns.
name: json-lint
on:
pull_request:
branches:
- main
paths:
- '*.json'
- .github/workflows/json-lint.yml
jobs:
json-lint:
uses: mdn/workflows/.github/workflows/json-lint.yml@main
with:
cache: "npm"
node-version: 18
target-repo: "mdn/workflows"
The markdown-lint
reusable action is located in .github/workflows/markdown-lint.yml
. This workflow will use the markdownlint-cli
to lint markdown files in the target repository. You can use the paths
filter to only trigger this workflow for specific files or file patterns. More on this in the usage section.
This reusable action depends on the following actions:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required
The node version to setup and use.
- This
input
is optional, with a default of 16.
Which package manager cache to use.
- This
input
is optional, with a default of yarn.
name: markdown-lint
on:
pull_request:
branches:
- main
paths:
- '*.md'
- .github/workflows/markdown-lint.yml
jobs:
markdown-lint:
uses: mdn/workflows/.github/workflows/markdown-lint.yml@main
with:
target-repo: "mdn/workflows"
Above you can see how the paths
filter is being used to specify specific files and file patterns.
name: markdown-lint
on:
pull_request:
branches:
- main
paths:
- '*.md'
- .github/workflows/markdown-lint.yml
jobs:
markdown-lint:
uses: mdn/workflows/.github/workflows/markdown-lint.yml@main
with:
cache: "npm"
node-version: 18
target-repo: "mdn/workflows"
The pr-check-redirects
reusable action is located in .github/workflows/pr-check-redirects.yml
. This workflow uses the Yari content validate-redirects
utility to validate the redirects file(s). You can use the paths
filter to trigger this workflow only for specific files or file patterns. More on this in the usage section.
This reusable action depends on the following actions:
Specify the target repository this action should run on. This is used to prevent actions from running on repositories other than the target repository. For example, specifying a target-repo
of mdn/workflows
will prevent the action from running on forks of mdn/workflows
.
- This
input
is required
The package manager cache to use.
- This
input
is optional, with the default valueyarn
.
The node version to setup and use.
- This
input
is optional, with the default value16
.
The target locale for which to check the redirects file(s).
- This
input
is optional. The default is all locales in the repository.
This will run for all locales in the target repository.
name: check-redirects
on:
pull_request:
branches:
- main
paths:
- files/**
- .github/workflows/pr-check-redirects.yml
jobs:
check-redirects:
uses: mdn/workflows/.github/workflows/pr-check-redirects.yml@main
with:
target-repo: "mdn/workflows"
Only run this for the en-us
locale, using npm
cache and Nodejs version 18
.
name: check-redirects
on:
pull_request:
branches:
- main
paths:
- files/**
- .github/workflows/pr-check-redirects.yml
jobs:
check-redirects:
uses: mdn/workflows/.github/workflows/pr-check-redirects.yml@main
with:
cahce: "npm"
node-version: 18
target-locale: "en-us"
target-repo: "mdn/workflows"