-
Notifications
You must be signed in to change notification settings - Fork 2.3k
58 lines (47 loc) · 2.09 KB
/
arewefastyet_comment.yml
File metadata and controls
58 lines (47 loc) · 2.09 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
# Adds a comment with a link to arewefastyet when the "Benchmark me" label is added.
name: arewefastyet comment
permissions: read-all
on:
pull_request_target:
types: [labeled]
jobs:
add_arewefastyet_comment:
name: Add arewefastyet comment
permissions:
pull-requests: write
runs-on: ubuntu-latest
if: github.event.label.name == 'Benchmark me'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Generate GitHub App token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-pull-requests: write
- name: Set token in environment
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
- name: Check if comment already exists
id: check_comment
run: |
# Get all comments on the PR
COMMENTS=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[].body')
# Check if arewefastyet comment already exists
if echo "$COMMENTS" | grep -q "This Pull Request is now handled by arewefastyet"; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "arewefastyet comment already exists"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Add arewefastyet comment
if: steps.check_comment.outputs.skip != 'true'
run: |
gh pr comment ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--body "Hello! :wave:
This Pull Request is now handled by arewefastyet. The current HEAD and future commits will be benchmarked.
You can find the performance comparison on the [arewefastyet website](https://benchmark.vitess.io/pr/${{ github.event.pull_request.number }})."