Skip to content

Commit

Permalink
Merge pull request #252 from Lombiq/issue/OSOE-676
Browse files Browse the repository at this point in the history
OSOE-676: Fixing that Create Jira issues for community activities doesn't work for external pull requests
  • Loading branch information
Piedone authored Sep 5, 2023
2 parents 65333a0 + a937175 commit 001a7b4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param
param
(
$GitHub,
$IssueComponent,
Expand Down Expand Up @@ -44,7 +44,7 @@ switch ($GitHub.event_name)
}
}
}
'pull_request'
'pull_request_target'
{
$summary = "Review `"$($GitHub.event.pull_request.title)`"$titleSuffix"
$description = $PullReqestJiraIssueDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ runs:
- name: Check for Jira Issue-Related Pull Request
id: issue-related-pr
env:
# Even though the trigger is pull_request_target, the event payload is pull_request (see
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target).
PR_TITLE: ${{ github.event.pull_request.title }}
shell: pwsh
run: |
$output = "${{ github.event.pull_request }}" -eq "" ? "False" : (Confirm-PullRequestTitle "$Env:PR_TITLE") -or $Env:GITHUB_HEAD_REF -Like "*issue*"
$output = "False"
if ("${{ github.event.pull_request }}" -ne "")
{
$output = (Confirm-PullRequestTitle "$Env:PR_TITLE") -or $Env:GITHUB_HEAD_REF -Like "*issue*"
}
Set-GitHubOutput "is-issue-pr" $output
- name: Login to Jira
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ on:
types: [created]
issues:
types: [opened]
pull_request:
pull_request_target:
types: [opened]

jobs:
create-jira-issues-for-community-activities:
name: Create Jira issues for community activities
uses: Lombiq/GitHub-Actions/.github/workflows/create-jira-issues-for-community-activities.yml@dev
secrets:
JIRA_BASE_URL: ${{ secrets.DEFAULT_JIRA_BASE_URL }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ on:

jobs:
create-jira-issues-for-community-activities:
name: Create Jira issues for community activities
runs-on: ubuntu-22.04
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Create Jira issues for community activities
uses: Lombiq/GitHub-Actions/.github/actions/create-jira-issues-for-community-activities@dev
uses: Lombiq/GitHub-Actions/.github/actions/create-jira-issues-for-community-activities@issue/OSOE-676
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Expand Down
4 changes: 2 additions & 2 deletions Docs/Workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ h1. Checklist
* [Issue completion checklist|https://example.com/checklist]
```

All three templates are optional and if not provided, defaults will be used.
All three templates are optional and if not provided, defaults will be used. Note that it's important to use the `pull_request_target` trigger instead of `pull_request` because the latter doesn't trigger for pull requests from forks, defeating the whole purpose of this workflow.

```yaml
name: Create Jira issues for community activities
Expand All @@ -254,7 +254,7 @@ on:
types: [created]
issues:
types: [opened]
pull_request:
pull_request_target:
types: [opened]
jobs:
Expand Down

0 comments on commit 001a7b4

Please sign in to comment.