-
Notifications
You must be signed in to change notification settings - Fork 7
30 lines (27 loc) · 1.08 KB
/
link_startrek.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
name: Link with Startrek
on:
pull_request: { branches: [main] }
env:
ISSUE_PATTERN: '[A-Z]+-[0-9]+'
jobs:
link:
runs-on: ubuntu-latest
steps:
- name: Parse issue ID
run: |
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: env.ISSUE_NUMBER
uses: fjogeleit/http-request-action@v1
with:
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