Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Jun 27, 2023
1 parent 911d737 commit 75031ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 107 deletions.
51 changes: 5 additions & 46 deletions .github/workflows/autolabel.yml
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 }}
6 changes: 3 additions & 3 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
- "completed"
workflows:
- "ORCA CI"

permissions:
contents: write
pull-requests: write

jobs:
automerge:
uses: acquia/cli/.github/workflows/automerge.yml@main
uses: acquia/.github/.github/workflows/automerge.yml@main
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
67 changes: 9 additions & 58 deletions .github/workflows/jira.yml
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 }}

0 comments on commit 75031ab

Please sign in to comment.