-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new action 'pre-commit-autoupdate' (#195)
Signed-off-by: Kenji Miyake <[email protected]> Signed-off-by: Kenji Miyake <[email protected]>
- Loading branch information
1 parent
242ab25
commit 764b105
Showing
2 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# pre-commit-autoupdate | ||
|
||
This action updates the versions of pre-commit hooks. | ||
|
||
It uses [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request/) for creating pull requests and [peter-evans/enable-pull-request-automerge](https://github.com/peter-evans/enable-pull-request-automerge) for enabling auto-merge. | ||
|
||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
sync-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate token | ||
id: generate-token | ||
uses: tibdex/github-app-token@v1 | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.PRIVATE_KEY }} | ||
|
||
- name: Run pre-commit-autoupdate | ||
uses: autowarefoundation/autoware-github-actions/pre-commit-autoupdate@v1 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
pre-commit-config: .pre-commit-config.yaml | ||
auto-merge-method: squash | ||
``` | ||
## Inputs | ||
| Name | Required | Description | | ||
| ----------------- | -------- | ----------------------------------------------------- | | ||
| token | true | The token for pull requests. | | ||
| pre-commit-config | true | The path to `.pre-commit-config.yaml`. | | ||
| pr-base | false | Refer to `peter-evans/create-pull-request`. | | ||
| pr-branch | false | The same as above. | | ||
| pr-title | false | The same as above. | | ||
| pr-commit-message | false | The same as above. | | ||
| pr-labels | false | The same as above. | | ||
| pr-assignees | false | The same as above. | | ||
| pr-reviewers | false | The same as above. | | ||
| auto-merge-method | false | Refer to `peter-evans/enable-pull-request-automerge`. | | ||
|
||
## Outputs | ||
|
||
None. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: pre-commit-autoupdate | ||
description: "" | ||
|
||
inputs: | ||
token: | ||
description: "" | ||
required: true | ||
pre-commit-config: | ||
description: "" | ||
required: true | ||
pr-base: | ||
description: "" | ||
required: false | ||
default: ${{ github.event.repository.default_branch }} | ||
pr-branch: | ||
description: "" | ||
required: false | ||
default: pre-commit-autoupdate | ||
pr-title: | ||
description: "" | ||
required: false | ||
default: "ci(pre-commit): autoupdate" | ||
pr-commit-message: | ||
description: "" | ||
required: false | ||
default: "ci(pre-commit): autoupdate" | ||
pr-labels: | ||
description: "" | ||
required: false | ||
default: "" | ||
pr-assignees: | ||
description: "" | ||
required: false | ||
default: "" | ||
pr-reviewers: | ||
description: "" | ||
required: false | ||
default: "" | ||
auto-merge-method: | ||
description: "" | ||
required: false | ||
default: "" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install pre-commit | ||
run: | | ||
python -m pip install pre-commit | ||
shell: bash | ||
|
||
- name: Run pre-commit | ||
run: | | ||
pre-commit autoupdate --config ${{ inputs.pre-commit-config }} | ||
shell: bash | ||
|
||
- name: Create PR | ||
id: create-pr | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ inputs.token }} | ||
base: ${{ inputs.pr-base }} | ||
branch: ${{ inputs.pr-branch }} | ||
title: ${{ inputs.pr-title }} | ||
commit-message: ${{ inputs.pr-commit-message }} | ||
body: ${{ steps.create-pr-body.outputs.body }} | ||
labels: ${{ inputs.pr-labels }} | ||
assignees: ${{ inputs.pr-assignees }} | ||
reviewers: ${{ inputs.pr-reviewers }} | ||
signoff: true | ||
delete-branch: true | ||
|
||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.create-pr.outputs.pull-request-url }}" | ||
shell: bash | ||
|
||
- name: Enable auto-merge | ||
if: ${{ inputs.auto-merge-method != '' && steps.create-pr.outputs.pull-request-operation == 'created' }} | ||
uses: peter-evans/enable-pull-request-automerge@v2 | ||
with: | ||
token: ${{ inputs.token }} | ||
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }} | ||
merge-method: ${{ inputs.auto-merge-method }} |