ci: create pull request action (#288)
Refactor pull request creation into composite action.
This commit is contained in:
committed by
GitHub
parent
88c126385a
commit
223e8f57b9
56
.github/actions/create-pull-request/action.yml
vendored
Normal file
56
.github/actions/create-pull-request/action.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: create-pull-request
|
||||||
|
description: Create Pull Request
|
||||||
|
inputs:
|
||||||
|
bot:
|
||||||
|
description: "Bot username"
|
||||||
|
required: false
|
||||||
|
default: "cadobot[bot]"
|
||||||
|
app_id:
|
||||||
|
description: "Bot App ID"
|
||||||
|
required: true
|
||||||
|
app_private_key:
|
||||||
|
description: "Bot App Private Key"
|
||||||
|
required: true
|
||||||
|
title:
|
||||||
|
description: "Pull request title"
|
||||||
|
required: true
|
||||||
|
branch:
|
||||||
|
description: "Branch name"
|
||||||
|
required: true
|
||||||
|
body:
|
||||||
|
description: "Body of the pull request"
|
||||||
|
required: true
|
||||||
|
draft:
|
||||||
|
description: "Create draft pull request"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Get Bot User
|
||||||
|
id: bot
|
||||||
|
uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const res = await github.rest.users.getByUsername({username: '${{ inputs.bot }}'});
|
||||||
|
for (const [key, value] of Object.entries(res.data)) {
|
||||||
|
core.setOutput(key, value)
|
||||||
|
}
|
||||||
|
- name: Generate App Token
|
||||||
|
uses: tibdex/github-app-token@586e1a624db6a5a4ac2c53daeeded60c5e3d50fe # v1.5.2
|
||||||
|
id: app
|
||||||
|
with:
|
||||||
|
app_id: ${{ inputs.app_id }}
|
||||||
|
private_key: ${{ inputs.app_private_key }}
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@bd72e1b7922d417764d27d30768117ad7da78a0e # v4.0.2
|
||||||
|
with:
|
||||||
|
token: ${{ steps.app.outputs.token }}
|
||||||
|
commit-message: ${{ inputs.title }}
|
||||||
|
author: "{{ steps.bot.outputs.login }} <${{ steps.bot.outputs.id }}+${{ steps.bot.outputs.login }}@users.noreply.github.com>"
|
||||||
|
branch: ${{ inputs.branch }}
|
||||||
|
base: master
|
||||||
|
delete-branch: true
|
||||||
|
draft: ${{ inputs.draft }}
|
||||||
|
title: ${{ inputs.title }}
|
||||||
|
body: ${{ inputs.body }}
|
||||||
14
.github/workflows/deps.yml
vendored
14
.github/workflows/deps.yml
vendored
@@ -22,19 +22,11 @@ jobs:
|
|||||||
run: go mod tidy
|
run: go mod tidy
|
||||||
- name: Diff
|
- name: Diff
|
||||||
run: git diff
|
run: git diff
|
||||||
- name: Generate Bot Token
|
- name: Create Pull Request
|
||||||
uses: tibdex/github-app-token@586e1a624db6a5a4ac2c53daeeded60c5e3d50fe # v1.5.2
|
uses: ./.github/actions/create-pull-request
|
||||||
id: bot
|
|
||||||
with:
|
with:
|
||||||
app_id: ${{ secrets.APP_ID }}
|
app_id: ${{ secrets.APP_ID }}
|
||||||
private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
- name: Create Pull Request
|
|
||||||
uses: peter-evans/create-pull-request@bd72e1b7922d417764d27d30768117ad7da78a0e # v4.0.2
|
|
||||||
with:
|
|
||||||
token: ${{ steps.bot.outputs.token }}
|
|
||||||
commit-message: "all: upgrade direct dependencies"
|
|
||||||
branch: auto-upgrade-deps
|
branch: auto-upgrade-deps
|
||||||
base: master
|
|
||||||
delete-branch: true
|
|
||||||
title: "all: upgrade direct dependencies"
|
title: "all: upgrade direct dependencies"
|
||||||
body: "Auto-generated upgrade of module dependencies."
|
body: "Auto-generated upgrade of module dependencies."
|
||||||
|
|||||||
14
.github/workflows/metadata.yml
vendored
14
.github/workflows/metadata.yml
vendored
@@ -26,19 +26,11 @@ jobs:
|
|||||||
run: ./script/generate
|
run: ./script/generate
|
||||||
- name: Diff
|
- name: Diff
|
||||||
run: git diff
|
run: git diff
|
||||||
- name: Generate Bot Token
|
- name: Create Pull Request
|
||||||
uses: tibdex/github-app-token@586e1a624db6a5a4ac2c53daeeded60c5e3d50fe # v1.5.2
|
uses: ./.github/actions/create-pull-request
|
||||||
id: bot
|
|
||||||
with:
|
with:
|
||||||
app_id: ${{ secrets.APP_ID }}
|
app_id: ${{ secrets.APP_ID }}
|
||||||
private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
- name: Create Pull Request
|
|
||||||
uses: peter-evans/create-pull-request@bd72e1b7922d417764d27d30768117ad7da78a0e # v4.0.2
|
|
||||||
with:
|
|
||||||
token: ${{ steps.bot.outputs.token }}
|
|
||||||
commit-message: "tests/thirdparty: update package metadata"
|
|
||||||
branch: auto-tests-thirdparty-update-metadata
|
branch: auto-tests-thirdparty-update-metadata
|
||||||
base: master
|
|
||||||
delete-branch: true
|
|
||||||
title: "tests/thirdparty: update package metadata"
|
title: "tests/thirdparty: update package metadata"
|
||||||
body: "Auto-generated update of third-party package metadata."
|
body: "Auto-generated update of third-party package metadata."
|
||||||
|
|||||||
Reference in New Issue
Block a user