From c39ed937f982c2be991ee8eff6e5a128b4c7e69a Mon Sep 17 00:00:00 2001 From: Trevor Shoe Date: Mon, 25 Nov 2024 14:07:29 -0500 Subject: [PATCH 1/2] Fix labels with spaces --- action.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 289897a..4fc9687 100644 --- a/action.yaml +++ b/action.yaml @@ -25,7 +25,7 @@ runs: echo "NeedsJiraUpdate=false" >> $GITHUB_ENV - if [ ${{ github.event_name }} != "issues" ] && [ ${{ github.event_name }} != "issue_comment" ]; then + if [ "${{ github.event_name }}" != "issues" ] && [ "${{ github.event_name }}" != "issue_comment" ]; then echo "This action only work on issue events. Please use on: issues or issue_comment to use this action." exit 1 fi @@ -37,7 +37,7 @@ runs: # Issue creation with label will trigger 2 events and run twice: one create, one labelled. # let just focus on labelling then for creating issues Jira-side. - if [ ${{ github.event_name }} == "issues" ] && [ ${{ github.event.action }} == "opened" ]; then + if [ "${{ github.event_name }}" == "issues" ] && [ "${{ github.event.action }}" == "opened" ]; then echo "Ignoring creation of issues as a label will trigger a second event." exit 0 fi @@ -46,7 +46,7 @@ runs: ## check if one label of labels is our jira label toconsider=${{ contains(github.event.issue.labels.*.name, inputs.label) }} ## second chance, this has just been unlabeled and needs to be deleted on Jira - if [ ${{ github.event.action }} == "unlabeled" ] && [ ${{ github.event.label.name }} == ${{ inputs.label }} ]; then + if [ "${{ github.event.action }}" == "unlabeled" ] && [ "${{ github.event.label.name }}" == "${{ inputs.label }}" ]; then toconsider=true fi if [ "${toconsider}" == false ]; then @@ -55,7 +55,7 @@ runs: fi # And finally, for the "labeled" event, we are only interested if the new added label is our desired one. - if [ ${{ github.event.action }} == "labeled" ] && [ ${{ github.event.label.name }} != ${{ inputs.label }} ]; then + if [ "${{ github.event.action }}" == "labeled" ] && [ "${{ github.event.label.name }}" != "${{ inputs.label }}" ]; then echo "Not interested in this action, skipping" exit 0 fi From d019f69067cea0e98967a6a2a78fc6e195b62159 Mon Sep 17 00:00:00 2001 From: Trevor Shoe Date: Mon, 25 Nov 2024 14:19:10 -0500 Subject: [PATCH 2/2] Account for weird labels --- action.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 4fc9687..f533dd6 100644 --- a/action.yaml +++ b/action.yaml @@ -20,6 +20,9 @@ runs: # run: echo '${{ toJSON(github) }}' # shell: bash - name: restrict action to labelled issues and issue comments + env: + label: ${{ github.event.label.name }} + jiraLabel: ${{ inputs.label }} run: | set -eux @@ -46,7 +49,7 @@ runs: ## check if one label of labels is our jira label toconsider=${{ contains(github.event.issue.labels.*.name, inputs.label) }} ## second chance, this has just been unlabeled and needs to be deleted on Jira - if [ "${{ github.event.action }}" == "unlabeled" ] && [ "${{ github.event.label.name }}" == "${{ inputs.label }}" ]; then + if [ "${{ github.event.action }}" == "unlabeled" ] && [ "$label" == "$jiraLabel" ]; then toconsider=true fi if [ "${toconsider}" == false ]; then @@ -55,7 +58,7 @@ runs: fi # And finally, for the "labeled" event, we are only interested if the new added label is our desired one. - if [ "${{ github.event.action }}" == "labeled" ] && [ "${{ github.event.label.name }}" != "${{ inputs.label }}" ]; then + if [ "${{ github.event.action }}" == "labeled" ] && [ "$label" != "$jiraLabel" ]; then echo "Not interested in this action, skipping" exit 0 fi