forked from scikit-learn/scikit-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 2.4 KB
/
Copy pathbot-lint-comment.yml
File metadata and controls
73 lines (63 loc) · 2.4 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
name: Bot linter comment
# We need these permissions to be able to post / update comments
permissions:
pull-requests: write
issues: write
on:
workflow_run:
workflows: ["Linter"]
types:
- completed
jobs:
bot-comment:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'cancelled' }}
steps:
- name: Define ARTIFACTS_DIR environment variable
run: |
echo "ARTIFACTS_DIR=${{ runner.temp }}/artifacts" >> "$GITHUB_ENV"
- name: Create temporary artifacts directory
run: mkdir -p "$ARTIFACTS_DIR"
- name: Download artifact
uses: actions/download-artifact@v7
with:
name: lint-log
path: ${{ runner.temp }}/artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
# Adapted from https://github.com/docker-mailserver/docker-mailserver/pull/4267#issuecomment-2484565209
# Unfortunately there is no easier way to do it
- name: Get PR number from triggering workflow information
env:
GH_TOKEN: ${{ github.token }}
PR_TARGET_REPO: ${{ github.repository }}
PR_BRANCH: |-
${{
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
|| github.event.workflow_run.head_branch
}}
run: |
gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \
--json 'number' \
--jq '"PR_NUMBER=\(.number)"' \
>> $GITHUB_ENV
- uses: actions/checkout@v6
with:
sparse-checkout: build_tools/get_comment.py
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Install dependencies
run: python -m pip install PyGithub
- name: Create/update GitHub comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
set -e
export LOG_FILE="$ARTIFACTS_DIR/linting_output.txt"
export VERSIONS_FILE="$ARTIFACTS_DIR/versions.txt"
python ./build_tools/get_comment.py