1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-12 14:48:58 +00:00

Add source of workflow dispatch in PR

This commit is contained in:
Sebastiaan van Steenis 2022-05-02 13:47:11 +02:00
parent 66c3152b1f
commit f6ea182c20
No known key found for this signature in database
GPG Key ID: B94666BE95B4B9C2

View File

@ -1,5 +1,18 @@
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:
contents: write
pull-requests: write
@ -41,9 +54,17 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
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({
title: "[${{ github.ref_name }}] go generate",
body: 'Auto-generated by GitHub Actions',
body: body,
owner: context.repo.owner,
repo: context.repo.repo,
base: "${{ github.ref_name }}",
@ -54,6 +75,13 @@ jobs:
issue_number: pr.number,
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');
return pr.html_url;
- name: Check outputs