Skip to content

Commit

Permalink
Fix both workflows running on PR triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Jul 9, 2024
1 parent daf143e commit 4afe823
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/port-issue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
port-issue:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/backport') || contains(github.event.comment.body, '/forwardport') && !github.event.issue.pull_request
if: ${{ !github.event.issue.pull_request && (contains(github.event.comment.body, '/backport') || contains(github.event.comment.body, '/forwardport')) }}
steps:
- name: Check org membership
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/port-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
port-pr:
runs-on: ubuntu-latest
if: (startsWith(github.event.comment.body, '/backport') || startsWith(github.event.comment.body, '/forwardport')) && github.event.issue.pull_request
if: ${{ github.event.issue.pull_request && (startsWith(github.event.comment.body, '/backport') || startsWith(github.event.comment.body, '/forwardport')) }}
steps:
- name: Check org membership
env:
Expand All @@ -34,7 +34,7 @@ jobs:
# Sanitize input
MILESTONE=${BODY_MILESTONE//[^a-zA-Z0-9\-\.]/}
if gh api repos/${GITHUB_REPOSITORY}/milestones --paginate | jq -e --arg MILESTONE "$MILESTONE" '.[] | select(.title == $MILESTONE)' > /dev/null; then
echo "Milestone exists"
echo "Milestone ${MILESTONE} exists" >> $GITHUB_STEP_SUMMARY
echo "milestone_exists=true" >> $GITHUB_ENV
echo "milestone=${MILESTONE}" >> $GITHUB_ENV
else
Expand Down Expand Up @@ -87,6 +87,7 @@ jobs:
ERROR_MESSAGE=$(cat error.log)
FORMATTED_ERROR_MESSAGE=$(printf "\n\`\`\`\n%s\n\`\`\`" "$ERROR_MESSAGE")
gh issue comment ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port PR, there was an error running git am -3: $FORMATTED_ERROR_MESSAGE"
echo "Port PR not created." >> $GITHUB_STEP_SUMMARY
else
git push origin $BRANCH
ORIGINAL_PR=$(gh pr view ${ORIGINAL_ISSUE_NUMBER} --json title,body,assignees)
Expand Down

0 comments on commit 4afe823

Please sign in to comment.