Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix labels with spaces #18

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ 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

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
Expand All @@ -37,7 +40,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
Expand All @@ -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
Expand All @@ -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
Expand Down