mirror of
https://code.forgejo.org/actions/git-backporting
synced 2025-03-14 22:27:02 +01:00
fix: gha skip whitespace trim on body (#73)
this also added a github workflow example
This commit is contained in:
parent
fa43ffc1dc
commit
29589a63b5
4 changed files with 136 additions and 4 deletions
4
dist/gha/index.js
vendored
4
dist/gha/index.js
vendored
|
@ -190,8 +190,8 @@ class GHAArgsParser extends args_parser_1.default {
|
|||
gitUser: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("git-user")),
|
||||
gitEmail: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("git-email")),
|
||||
title: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("title")),
|
||||
body: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("body")),
|
||||
bodyPrefix: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("body-prefix")),
|
||||
body: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("body", { trimWhitespace: false })),
|
||||
bodyPrefix: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("body-prefix", { trimWhitespace: false })),
|
||||
bpBranchName: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("bp-branch-name")),
|
||||
reviewers: (0, args_utils_1.getAsCleanedCommaSeparatedList)((0, core_1.getInput)("reviewers")),
|
||||
assignees: (0, args_utils_1.getAsCleanedCommaSeparatedList)((0, core_1.getInput)("assignees")),
|
||||
|
|
53
examples/on-pr-merge/automated-workflow.yaml
Normal file
53
examples/on-pr-merge/automated-workflow.yaml
Normal file
|
@ -0,0 +1,53 @@
|
|||
name: Automated Backporting on PR merge using Git Backporting
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [closed, labeled]
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
compute-targets:
|
||||
if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged }}
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
target-branches: ${{ steps.set-targets.outputs.targets }}
|
||||
env:
|
||||
LABELS: ${{ toJSON(github.event.pull_request.labels) }}
|
||||
steps:
|
||||
- name: Set target branches
|
||||
id: set-targets
|
||||
uses: kiegroup/kie-ci/.ci/actions/parse-labels@main
|
||||
with:
|
||||
labels: ${LABELS}
|
||||
|
||||
backporting:
|
||||
if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged && needs.compute-targets.outputs.target-branches != '[]' }}
|
||||
name: "[${{ matrix.target-branch }}] - Backporting"
|
||||
runs-on: ubuntu-latest
|
||||
needs: compute-targets
|
||||
strategy:
|
||||
matrix:
|
||||
target-branch: ${{ fromJSON(needs.compute-targets.outputs.target-branches) }}
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Backporting
|
||||
uses: ./
|
||||
with:
|
||||
dry-run: true
|
||||
pull-request: ${{ github.event.pull_request.html_url }}
|
||||
target-branch: ${{ matrix.target-branch }}
|
||||
auth: "${{ env.GITHUB_TOKEN }}"
|
||||
title: "[${{ matrix.target-branch }}] ${{ github.event.pull_request.title }}"
|
||||
body-prefix: "**Backport:** ${{ github.event.pull_request.html_url }}\r\n\r\n**Note**: comment 'ok to test' to properly launch Jenkins jobs\r\n\r\n"
|
||||
body: "${{ github.event.pull_request.body }}"
|
||||
labels: "cherry-pick :cherries:"
|
||||
inherit-labels: false
|
||||
bp-branch-name: "${{ matrix.target-branch }}_${{ github.event.pull_request.head.ref }}"
|
79
examples/on-pr-merge/pr-merge-event.json
Normal file
79
examples/on-pr-merge/pr-merge-event.json
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"pull_request": {
|
||||
"url": "https://api.github.com/repos/lampajr/backporting-example/pulls/66",
|
||||
"html_url": "https://github.com/lampajr/backporting-example/pull/66",
|
||||
"diff_url": "https://github.com/lampajr/backporting-example/pull/66.diff",
|
||||
"patch_url": "https://github.com/lampajr/backporting-example/pull/66.patch",
|
||||
"issue_url": "https://api.github.com/repos/lampajr/backporting-example/issues/66",
|
||||
"number": 66,
|
||||
"state": "closed",
|
||||
"title": "Feature1: multiple changes",
|
||||
"user": {
|
||||
"login": "lampajr"
|
||||
},
|
||||
"body": "This is the body of multiple change",
|
||||
"merge_commit_sha": "0bcaa01cdd509ca434e123d2e2b9ce7f66234bd7",
|
||||
"assignee": null,
|
||||
"assignees": [
|
||||
|
||||
],
|
||||
"requested_reviewers": [
|
||||
|
||||
],
|
||||
"requested_teams": [
|
||||
|
||||
],
|
||||
"labels": [
|
||||
{
|
||||
"name": "backport-develop",
|
||||
"color": "AB975B",
|
||||
"default": false,
|
||||
"description": ""
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"label": "lampajr:feature1",
|
||||
"ref": "feature1",
|
||||
"sha": "69e49388ea2ca9be272b188a9271806d487bf01e",
|
||||
"user": {
|
||||
"login": "lampajr"
|
||||
},
|
||||
"repo": {
|
||||
"name": "backporting-example",
|
||||
"full_name": "lampajr/backporting-example",
|
||||
"owner": {
|
||||
"login": "lampajr"
|
||||
},
|
||||
"html_url": "https://github.com/lampajr/backporting-example",
|
||||
"clone_url": "https://github.com/lampajr/backporting-example.git"
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"label": "lampajr:main",
|
||||
"ref": "main",
|
||||
"sha": "c85b8fcdb741814b3e90e6e5729455cf46ff26ea",
|
||||
"user": {
|
||||
"login": "lampajr"
|
||||
},
|
||||
"repo": {
|
||||
"name": "backporting-example",
|
||||
"full_name": "lampajr/backporting-example",
|
||||
"owner": {
|
||||
"login": "lampajr"
|
||||
},
|
||||
"html_url": "https://github.com/lampajr/backporting-example",
|
||||
"description": "Playground repository for automated backporting testing",
|
||||
"url": "https://api.github.com/repos/lampajr/backporting-example",
|
||||
"issues_url": "https://api.github.com/repos/lampajr/backporting-example/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/lampajr/backporting-example/pulls{/number}",
|
||||
"clone_url": "https://github.com/lampajr/backporting-example.git"
|
||||
}
|
||||
},
|
||||
"merged": true,
|
||||
"merged_by": {
|
||||
"login": "lampajr"
|
||||
},
|
||||
"comments": 0,
|
||||
"commits": 2
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ export default class GHAArgsParser extends ArgsParser {
|
|||
gitUser: getOrUndefined(getInput("git-user")),
|
||||
gitEmail: getOrUndefined(getInput("git-email")),
|
||||
title: getOrUndefined(getInput("title")),
|
||||
body: getOrUndefined(getInput("body")),
|
||||
bodyPrefix: getOrUndefined(getInput("body-prefix")),
|
||||
body: getOrUndefined(getInput("body", { trimWhitespace: false })),
|
||||
bodyPrefix: getOrUndefined(getInput("body-prefix", { trimWhitespace: false })),
|
||||
bpBranchName: getOrUndefined(getInput("bp-branch-name")),
|
||||
reviewers: getAsCleanedCommaSeparatedList(getInput("reviewers")),
|
||||
assignees: getAsCleanedCommaSeparatedList(getInput("assignees")),
|
||||
|
|
Loading…
Add table
Reference in a new issue