diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 20:09:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 20:09:42 +0000 |
commit | c961c66297d5f5732d6d1ed1ee7af22b03e6879e (patch) | |
tree | 1844b742f17ca97ff73c212bc59701bbd7fad3b8 /.github/actions/rn-pr-labeler-action | |
parent | Releasing debian version 0.10.1-1. (diff) | |
download | eos-downloader-c961c66297d5f5732d6d1ed1ee7af22b03e6879e.tar.xz eos-downloader-c961c66297d5f5732d6d1ed1ee7af22b03e6879e.zip |
Merging upstream version 0.10.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '.github/actions/rn-pr-labeler-action')
-rw-r--r-- | .github/actions/rn-pr-labeler-action/action.yml | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/.github/actions/rn-pr-labeler-action/action.yml b/.github/actions/rn-pr-labeler-action/action.yml new file mode 100644 index 0000000..a685ffc --- /dev/null +++ b/.github/actions/rn-pr-labeler-action/action.yml @@ -0,0 +1,41 @@ +name: "rn-pr-labeler" +author: "@gmuloc" +description: "Parse a conventional commit compliant PR title and add it as a label to the PR with the prefix 'rn: '" +inputs: + auto_create_label: + description: "Boolean to indicate if the label should be auto created" + required: false + default: false +runs: + using: "composite" + steps: + - name: 'Looking up existing "rn:" label' + run: | + echo "OLD_LABEL=$(gh pr view ${{ github.event.pull_request.number }} --json labels -q .labels[].name | grep 'rn: ')" >> $GITHUB_ENV + shell: bash + - name: 'Delete existing "rn:" label if found' + run: gh pr edit ${{ github.event.pull_request.number }} --remove-label "${{ env.OLD_LABEL }}" + shell: bash + if: ${{ env.OLD_LABEL }} + - name: Set Label + # Using toJSON to support ' and " in commit messages + # https://stackoverflow.com/questions/73363167/github-actions-how-to-escape-characters-in-commit-message + run: echo "LABEL=$(echo ${{ toJSON(github.event.pull_request.title) }} | cut -d ':' -f 1 | tr -d ' ')" >> $GITHUB_ENV + shell: bash + # an alternative to verifying if the target label already exist is to + # create the label with --force in the next step, it will keep on changing + # the color of the label though so it may not be desirable. + - name: Check if label exist + run: | + EXIST=$(gh label list -L 100 --search "rn:" --json name -q '.[] | select(.name=="rn: ${{ env.LABEL }}").name') + echo "EXIST=$EXIST" >> $GITHUB_ENV + shell: bash + - name: Create Label if auto-create and label does not exist already + run: | + gh label create "rn: ${{ env.LABEL }}" + shell: bash + if: ${{ inputs.auto_create_label && ! env.EXIST }} + - name: Labelling PR + run: | + gh pr edit ${{ github.event.pull_request.number }} --add-label "rn: ${{ env.LABEL }}" + shell: bash |