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

Support linking PRs with tickets through commit messages #35

Merged
merged 1 commit into from
Aug 16, 2023
Merged
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
23 changes: 13 additions & 10 deletions .github/workflows/link_startrek.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
name: startrek link
name: Link with Startrek

on:
pull_request: { branches: [main] }

env:
ISSUE_PATTERN: '[A-Z]+-[0-9]+'

jobs:
link_with_startrek:
link:
runs-on: ubuntu-latest
steps:
- name: parse_branch_name
id: parse_branch_name
- name: Parse issue ID
run: |
if [[ ${{ github.head_ref }} =~ ^([A-Za-z]+\-[0-9]+).*$ ]]; then
echo issue_number="${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
LAST_COMMIT_MESSAGE="$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.event.pull_request.commits_url }}" | jq -r .[-1].commit.message)"
if [[ "$LAST_COMMIT_MESSAGE" =~ \[($ISSUE_PATTERN)\] || "${{ github.head_ref }}" =~ ^($ISSUE_PATTERN) ]]; then
echo ISSUE_NUMBER="${BASH_REMATCH[1]}" >> "${GITHUB_ENV}"
fi
- name: link_issue
if: steps.parse_branch_name.outputs.issue_number
- name: Link issue
if: env.ISSUE_NUMBER
uses: fjogeleit/http-request-action@v1
with:
url: 'https://st-api.yandex-team.ru/v2/issues/${{ steps.parse_branch_name.outputs.issue_number }}'
url: 'https://st-api.yandex-team.ru/v2/issues/${{ env.ISSUE_NUMBER }}'
method: 'LINK'
customHeaders: >
{
"Link": "<${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.number }}>; rel=\"relates\"",
"Authorization": "OAuth ${{ secrets.OAUTH_STARTREK_TOKEN }}"
}
ignoreStatusCodes: '409'
ignoreStatusCodes: 409