-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (46 loc) · 1.68 KB
/
labeler.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
name: "Pull Request Labeler"
on:
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: formance-runner
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- uses: actions/labeler@v5
with:
sync-labels: true
- name: Retrieve chart changes
id: chart_changes
run: |
CHARTS=$(git diff origin/main --stat | grep -oE 'charts/[^/]+/' | sed 's|charts/||;s|/||' | sort -u | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "Changed charts: $CHARTS"
echo "::set-output name=changed_charts::$CHARTS"
- name: Label PR based on chart changes
if: steps.chart_changes.outputs.changed_charts != ''
uses: actions/github-script@v7
env:
CHARTS: ${{ steps.chart_changes.outputs.changed_charts }}
with:
script: |
const charts = JSON.parse(process.env.CHARTS);
const labels = charts.map(chart => `chart-${chart.trim()}`).filter(label => label.length > 0);
if (labels.length > 0) {
console.log(`Applying labels: ${labels.join(', ')}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
} else {
console.log('No charts changed, skipping labeling.');
}