-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (70 loc) · 2.72 KB
/
estimate.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
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
77
name: Estimate
on:
pull_request:
jobs:
estimate:
name: Estimate
if: vars.JIRA_PROJECT_ID != ''
runs-on: ubuntu-latest
steps:
- name: Start Check Run
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
CHECK_ID=$(gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'name=Estimator' \
-f 'head_sha=${{ github.event.pull_request.head.sha }}' \
-f 'status=in_progress' \
-f 'output[title]=🎲 Estimation in progress' \
-f 'output[summary]=🎲 Estimation in progress' \
/repos/${{ github.repository }}/check-runs --jq '.id')
echo "check_id=$CHECK_ID" >> $GITHUB_OUTPUT
- name: Install estimator
run: npm install -g @amazeelabs/estimator
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find common ancestor
id: ancestor
env:
BASE_BRANCH: ${{ github.base_ref }}
run:
echo "hash=$(git merge-base --fork-point origin/$BASE_BRANCH)" >>
$GITHUB_OUTPUT
- name: Estimate
id: estimate
env:
JIRA_PROJECT_ID: ${{ vars.JIRA_PROJECT_ID }}
PARENT_COMMIT: ${{ steps.ancestor.outputs.hash }}
DASHBOARD_ACCESS_TOKEN: ${{ secrets.DASHBOARD_ACCESS_TOKEN }}
run: echo "result=$(amazeelabs-estimator estimate)" >> $GITHUB_OUTPUT
continue-on-error: true
- name: Report success
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'name=Estimator' \
-f 'head_sha=${{ github.event.pull_request.head.sha }}' \
-f 'conclusion=success' \
-f 'output[title]=🎲 ${{ steps.estimate.outputs.result }}' \
-f 'output[summary]=🎲 ${{ steps.estimate.outputs.result }}' \
/repos/${{ github.repository }}/check-runs/${{ steps.check.outputs.check_id }}
if: steps.estimate.outputs.result != ''
- name: Report error
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'name=Estimator' \
-f 'head_sha=${{ github.event.pull_request.head.sha }}' \
-f 'conclusion=failure' \
-f 'output[title]=💥 Estimation failed' \
-f 'output[summary]=💥 Estimation failed' \
/repos/${{ github.repository }}/check-runs/${{ steps.check.outputs.check_id }}
if: steps.estimate.outputs.result == ''