-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
911d737
commit 75031ab
Showing
3 changed files
with
17 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,11 @@ | ||
name: Auto-label pull requests | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, synchronize, reopened, labeled, unlabeled] | ||
|
||
permissions: | ||
pull-requests: write | ||
jobs: | ||
autolabel: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
pull-requests: write | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_PR: ${{ github.event.pull_request.number }} | ||
steps: | ||
- name: Get linked issue label | ||
run: | | ||
ISSUE_LABEL=$(gh api graphql -F owner=$GITHUB_REPOSITORY_OWNER -F name='blt' -F number=$GITHUB_PR -f query=' | ||
query($owner:String!, $name:String!, $number:Int!){ | ||
repository(owner:$owner, name:$name) { | ||
pullRequest(number:$number) { | ||
closingIssuesReferences (first:1) { | ||
edges { | ||
node { | ||
labels (first:1) { | ||
edges { | ||
node { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
' --jq '.data.repository.pullRequest.closingIssuesReferences.edges.[].node.labels.edges.[].node.name') | ||
echo "ISSUE_LABEL=$ISSUE_LABEL" >> $GITHUB_ENV | ||
- name: Apply label | ||
if: env.ISSUE_LABEL != '' | ||
run: gh pr edit https://github.com/$GITHUB_REPOSITORY/pull/$GITHUB_PR --add-label "$ISSUE_LABEL" | ||
require_label: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
pull-requests: read | ||
needs: autolabel | ||
steps: | ||
- run: gh pr view --json labels https://github.com/$GITHUB_REPOSITORY/pull/$GITHUB_PR | jq -r '.labels[0].name' | grep -q 'null' && echo "You must apply at least one label" && exit 1 || exit 0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_PR: ${{ github.event.pull_request.number }} | ||
uses: acquia/.github/.github/workflows/autolabel.yml@main | ||
secrets: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,15 @@ | ||
name: Sync GitHub issues to Jira | ||
on: | ||
issues: | ||
types: | ||
- opened | ||
- closed | ||
|
||
name: Sync GitHub issues to Jira | ||
|
||
permissions: | ||
issues: write | ||
jobs: | ||
open: | ||
if: github.event.action == 'opened' | ||
runs-on: ubuntu-22.04 | ||
name: Create new tickets in Jira | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: Login | ||
uses: acquia/gajira-login@bearer | ||
env: | ||
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} | ||
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | ||
- name: Create | ||
id: create | ||
uses: acquia/gajira-create@bearer | ||
with: | ||
project: BLT | ||
issuetype: Task | ||
summary: ${{ github.event.issue.title }} | ||
description: ${{ github.event.issue.html_url }} | ||
fields: '{"components": [{"id": "21989"}]}' | ||
- name: Update Github issue with Jira ticket prefix | ||
run: 'gh issue edit $GH_ISSUE --title "$JIRA_ISSUE: $ISSUE_TITLE"' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_ISSUE: ${{ github.event.issue.html_url }} | ||
JIRA_ISSUE: ${{ steps.create.outputs.issue }} | ||
ISSUE_TITLE: ${{ github.event.issue.title }} | ||
close: | ||
if: github.event.action == 'closed' | ||
runs-on: ubuntu-22.04 | ||
name: Comment in Jira | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: Get Jira issue | ||
id: get-issue | ||
run: | | ||
if [[ "$ISSUE_TITLE" =~ ^(BLT-[0-9]+): ]]; then | ||
echo "issue=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
ISSUE_TITLE: ${{ github.event.issue.title }} | ||
- name: Login | ||
if: steps.get-issue.outputs.issue | ||
uses: acquia/gajira-login@bearer | ||
env: | ||
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} | ||
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | ||
- name: Comment | ||
if: steps.get-issue.outputs.issue | ||
uses: acquia/gajira-comment@bearer | ||
with: | ||
issue: ${{ steps.get-issue.outputs.issue }} | ||
comment: The GitHub issue corresponding to this ticket has been closed | ||
jira: | ||
uses: acquia/.github/.github/workflows/jira.yml@main | ||
secrets: | ||
jira-base-url: ${{ secrets.JIRA_BASE_URL }} | ||
jira-api-token: ${{ secrets.JIRA_API_TOKEN }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |