-
Notifications
You must be signed in to change notification settings - Fork 8
85 lines (77 loc) · 2.39 KB
/
Copy pathci-per-commit.yaml
File metadata and controls
85 lines (77 loc) · 2.39 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
77
78
79
80
81
82
83
84
85
name: CI per commit
on:
push:
branches:
- main
pull_request:
types: [labeled]
branches:
- main
permissions:
contents: read
jobs:
check-label:
name: Check ci:per-commit label
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
has_label: ${{ steps.check.outputs.has_label }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check for label
id: check
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
REPOSITORY: ${{ github.repository }}
SHA: ${{ github.sha }}
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: |
.github/scripts/check-ci-per-commit-label.sh \
"$EVENT_NAME" \
"$REPOSITORY" \
"$SHA" \
"$LABELS" \
>> "$GITHUB_OUTPUT"
ci-per-commit:
name: CI per commit
needs: check-label
if: needs.check-label.outputs.has_label == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: "3.13"
- name: Determine commit range
id: range
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_SHA: ${{ github.sha }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
BASE="$PR_BASE_SHA"
HEAD="$PR_HEAD_SHA"
else
BASE="$PUSH_BEFORE"
HEAD="$PUSH_SHA"
fi
echo "base=${BASE}" >> "$GITHUB_OUTPUT"
echo "head=${HEAD}" >> "$GITHUB_OUTPUT"
- name: Run CI on each commit
env:
BASE: ${{ steps.range.outputs.base }}
HEAD: ${{ steps.range.outputs.head }}
run: .github/scripts/run-ci-per-commit.sh "$BASE" "$HEAD"