diff --git a/.github/actions/create-pull-request/action.yml b/.github/actions/create-pull-request/action.yml new file mode 100644 index 0000000..e5716de --- /dev/null +++ b/.github/actions/create-pull-request/action.yml @@ -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 }} diff --git a/.github/workflows/deps.yml b/.github/workflows/deps.yml index 63aa53e..aa1be9d 100644 --- a/.github/workflows/deps.yml +++ b/.github/workflows/deps.yml @@ -22,19 +22,11 @@ jobs: run: go mod tidy - name: Diff run: git diff - - name: Generate Bot Token - uses: tibdex/github-app-token@586e1a624db6a5a4ac2c53daeeded60c5e3d50fe # v1.5.2 - id: bot + - name: Create Pull Request + uses: ./.github/actions/create-pull-request with: app_id: ${{ secrets.APP_ID }} - 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" + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} branch: auto-upgrade-deps - base: master - delete-branch: true title: "all: upgrade direct dependencies" body: "Auto-generated upgrade of module dependencies." diff --git a/.github/workflows/metadata.yml b/.github/workflows/metadata.yml index 21d6d3b..0dbdb06 100644 --- a/.github/workflows/metadata.yml +++ b/.github/workflows/metadata.yml @@ -26,19 +26,11 @@ jobs: run: ./script/generate - name: Diff run: git diff - - name: Generate Bot Token - uses: tibdex/github-app-token@586e1a624db6a5a4ac2c53daeeded60c5e3d50fe # v1.5.2 - id: bot + - name: Create Pull Request + uses: ./.github/actions/create-pull-request with: app_id: ${{ secrets.APP_ID }} - 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" + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} branch: auto-tests-thirdparty-update-metadata - base: master - delete-branch: true title: "tests/thirdparty: update package metadata" body: "Auto-generated update of third-party package metadata."