Add source of workflow dispatch in PR
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
