-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto-link-task.yml
More file actions
76 lines (61 loc) · 2.27 KB
/
auto-link-task.yml
File metadata and controls
76 lines (61 loc) · 2.27 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# GitScrum - Auto Link Task
#
# Automatically links commits and PRs to GitScrum tasks:
# - Extracts task code from branch name
# - Links PR URL to the task
# - Records commit SHA in task history
#
# Copy to: .github/workflows/gitscrum-link-task.yml
name: GitScrum Link Task
on:
push:
branches:
- 'feature/**'
- 'bugfix/**'
- 'hotfix/**'
- 'task/**'
pull_request:
types: [opened]
env:
GITSCRUM_ACCESS_TOKEN: ${{ secrets.GITSCRUM_ACCESS_TOKEN }}
jobs:
link-commit:
name: Link Commit to Task
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Install GitScrum CLI
run: curl -sL https://raw.githubusercontent.com/gitscrum-core/cli/main/install.sh | sh
- name: Extract Task & Link
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
TASK_CODE=$(echo "$BRANCH" | grep -oE '[A-Z]{2,5}-[0-9]+' | head -1)
if [ -z "$TASK_CODE" ]; then
echo "No task code in branch: $BRANCH"
exit 0
fi
echo "📌 Linking commit to $TASK_CODE"
gitscrum tasks update "$TASK_CODE" \
--add-commit "${{ github.sha }}" \
--note "Commit: ${{ github.event.head_commit.message }}"
echo "✅ Linked ${{ github.sha }} to $TASK_CODE" >> $GITHUB_STEP_SUMMARY
link-pr:
name: Link PR to Task
if: github.event_name == 'pull_request' && github.event.action == 'opened'
runs-on: ubuntu-latest
steps:
- name: Install GitScrum CLI
run: curl -sL https://raw.githubusercontent.com/gitscrum-core/cli/main/install.sh | sh
- name: Extract Task & Link PR
run: |
BRANCH="${{ github.head_ref }}"
TASK_CODE=$(echo "$BRANCH" | grep -oE '[A-Z]{2,5}-[0-9]+' | head -1)
if [ -z "$TASK_CODE" ]; then
echo "No task code in branch: $BRANCH"
exit 0
fi
echo "📌 Linking PR to $TASK_CODE"
gitscrum tasks pr "$TASK_CODE" \
--url "${{ github.event.pull_request.html_url }}" \
--title "${{ github.event.pull_request.title }}"
echo "✅ Linked PR #${{ github.event.pull_request.number }} to $TASK_CODE" >> $GITHUB_STEP_SUMMARY