forked from grafana/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 46
99 lines (87 loc) · 3.24 KB
/
pull-request.yaml
File metadata and controls
99 lines (87 loc) · 3.24 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Pull Request
permissions: {}
on:
pull_request:
branches:
- main
types: ["opened", "reopened", "synchronize", "edited"]
jobs:
check-multiple-chart-changes:
name: Check Multiple Chart Changes
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
changed: ${{ steps.list-changed.outputs.changed }}
changed_list: ${{ steps.list-changed.outputs.changed_list }}
steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Helm
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
with:
# renovate: github=helm/helm
version: v4.1.4
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Set up chart-testing
uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0
with:
# renovate: github=helm/chart-testing
version: v3.14.0
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed="$(ct list-changed --config .github/linters/ct.yaml)"
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "changed_list=\"${changed//$'\n'/ }\"" >> "$GITHUB_OUTPUT"
fi
- name: check for multiple chart changes
if: steps.list-changed.outputs.changed == 'true'
run: |
COUNT=$(echo "$CHANGED_LIST" | wc -w)
if [ "$COUNT" -gt 1 ]; then
echo "Error: ($COUNT) charts changed. Please create separate PRs for each chart." >&2
exit 1
fi
env:
CHANGED_LIST: ${{ steps.list-changed.outputs.changed_list }}
check-title:
name: Check Title
needs: check-multiple-chart-changes
if: needs.check-multiple-chart-changes.outputs.changed == 'true'
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Validate PR Title format
run: |
CHANGED_LIST="${CHANGED_LIST//\"/}"
# Derive chart name from the changed path and validate it.
if [[ "$CHANGED_LIST" == */* ]]; then
CHART_NAME="${CHANGED_LIST##*/}"
else
echo "Error: Unexpected chart identifier '$CHANGED_LIST'. Expected a path containing '/'." >&2
exit 1
fi
if [[ -z "$CHART_NAME" ]]; then
echo "Error: Derived chart name is empty. Original value: '$CHANGED_LIST'." >&2
exit 1
fi
# Optional sanity check: ensure chart name contains only expected characters.
if ! [[ "$CHART_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
echo "Error: Derived chart name '$CHART_NAME' contains unexpected characters." >&2
exit 1
fi
if [[ "$PR_TITLE" != "[${CHART_NAME}] "* ]]; then
echo "PR title must start with '[${CHART_NAME}] '." >&2
exit 1
fi
env:
CHANGED_LIST: ${{ needs.check-multiple-chart-changes.outputs.changed_list }}
PR_TITLE: ${{ github.event.pull_request.title }}