mirror of
https://github.com/rancher/rke.git
synced 2025-07-13 07:04:52 +00:00
Add source of workflow dispatch in PR
This commit is contained in:
parent
66c3152b1f
commit
f6ea182c20
32
.github/workflows/git-actions-go-generate.yml
vendored
32
.github/workflows/git-actions-go-generate.yml
vendored
@ -1,5 +1,18 @@
|
|||||||
name: Go Generate
|
name: Go Generate
|
||||||
on: workflow_dispatch
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
source_url:
|
||||||
|
type: string
|
||||||
|
description: "URL of the source for this workflow run"
|
||||||
|
source_author:
|
||||||
|
type: string
|
||||||
|
description: "Username of the source for this workflow run"
|
||||||
|
|
||||||
|
env:
|
||||||
|
INPUT_SOURCE_URL: ${{ github.event.inputs.source_url }}
|
||||||
|
INPUT_SOURCE_AUTHOR: ${{ github.event.inputs.source_author }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
@ -41,9 +54,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
|
let body = 'Auto-generated by GitHub Actions\n\n'
|
||||||
|
if ( `${ process.env.INPUT_SOURCE_URL }` ) {
|
||||||
|
body += `\nSource URL: ${ process.env.INPUT_SOURCE_URL }`
|
||||||
|
}
|
||||||
|
if ( `${ process.env.INPUT_SOURCE_AUTHOR }` ) {
|
||||||
|
body += `\nSource AUTHOR: @${ process.env.INPUT_SOURCE_AUTHOR}`
|
||||||
|
}
|
||||||
|
|
||||||
const { data: pr } = await github.rest.pulls.create({
|
const { data: pr } = await github.rest.pulls.create({
|
||||||
title: "[${{ github.ref_name }}] go generate",
|
title: "[${{ github.ref_name }}] go generate",
|
||||||
body: 'Auto-generated by GitHub Actions',
|
body: body,
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
base: "${{ github.ref_name }}",
|
base: "${{ github.ref_name }}",
|
||||||
@ -54,6 +75,13 @@ jobs:
|
|||||||
issue_number: pr.number,
|
issue_number: pr.number,
|
||||||
labels: ["status/auto-created"],
|
labels: ["status/auto-created"],
|
||||||
});
|
});
|
||||||
|
if ( `${ process.env.INPUT_SOURCE_AUTHOR }` ) {
|
||||||
|
await github.rest.issues.addAssignees({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
assignees: [`${ process.env.INPUT_SOURCE_AUTHOR}`],
|
||||||
|
});
|
||||||
|
}
|
||||||
console.log('Created new pull request');
|
console.log('Created new pull request');
|
||||||
return pr.html_url;
|
return pr.html_url;
|
||||||
- name: Check outputs
|
- name: Check outputs
|
||||||
|
Loading…
Reference in New Issue
Block a user