forked from janus-idp/helm-backstage
-
Notifications
You must be signed in to change notification settings - Fork 36
149 lines (121 loc) · 4.83 KB
/
Copy pathsync-lightspeed-configs.yaml
File metadata and controls
149 lines (121 loc) · 4.83 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Sync Lightspeed Configs
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
sync-lightspeed:
name: Sync Lightspeed Configs (${{ matrix.branch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
- release-1.10
concurrency:
group: ${{ github.workflow }}-${{ matrix.branch }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: v3.21.3
- name: Set up yq
uses: mikefarah/yq@1b9b4ac5187171d2e5e3129be0cfa827c7f9d53d # v4.53.3
with:
cmd: yq --version
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: 3.14
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version: ^1
- name: Set up helm-docs
run: go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Sync Lightspeed config files
run: ./hack/sync-lightspeed-configs.sh --ref ${{ matrix.branch }}
- name: Check for changes
id: changes
run: |
if git diff --quiet charts/backstage/files/lightspeed/; then
echo "No changes from upstream."
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "Changes detected from upstream."
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Get current chart version
if: steps.changes.outputs.has_changes == 'true'
id: get_version
uses: mikefarah/yq@1b9b4ac5187171d2e5e3129be0cfa827c7f9d53d # v4.53.3
with:
cmd: yq '.version' charts/backstage/Chart.yaml
- name: Compute next patch version
if: steps.changes.outputs.has_changes == 'true'
id: semver
uses: actions-ecosystem/action-bump-semver@34e334551143a5301f38c830e44a22273c6ff5c5 # v1
with:
current_version: ${{ steps.get_version.outputs.result }}
level: patch
- name: Bump chart version
if: steps.changes.outputs.has_changes == 'true'
uses: mikefarah/yq@1b9b4ac5187171d2e5e3129be0cfa827c7f9d53d # v4.53.3
with:
cmd: yq -i '.version = "${{ steps.semver.outputs.new_version }}"' charts/backstage/Chart.yaml
- name: Run pre-commit
if: steps.changes.outputs.has_changes == 'true'
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
continue-on-error: true
- name: Commit changes and open PR
if: steps.changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ steps.semver.outputs.new_version }}
TARGET_BRANCH: ${{ matrix.branch }}
run: |
TITLE="chore(lightspeed): sync config files and bump chart to ${NEW_VERSION}"
BRANCH="chore/sync-lightspeed-configs-${TARGET_BRANCH}"
EXISTING_PR=$(gh pr list --head "${BRANCH}" --base "${TARGET_BRANCH}" --state open --json number --jq '.[0].number // empty')
git checkout -b "${BRANCH}"
git add -A
if git diff --cached --quiet; then
echo "No staged changes to commit."
exit 0
fi
git commit -m "${TITLE}"
if [ -n "${EXISTING_PR}" ]; then
echo "Updating existing PR #${EXISTING_PR}."
git push --force origin "${BRANCH}"
else
git push origin "${BRANCH}"
BODY=$(cat <<EOF
Automated nightly sync of Lightspeed config files from [redhat-ai-dev/lightspeed-configs @ ${TARGET_BRANCH}](https://github.com/redhat-ai-dev/lightspeed-configs/tree/${TARGET_BRANCH}).
Bumped chart version to **${NEW_VERSION}**.
### Synced files
- \`charts/backstage/files/lightspeed/lightspeed-stack.yaml\`
- \`charts/backstage/files/lightspeed/config.yaml\`
- \`charts/backstage/files/lightspeed/rhdh-profile.py\`
- \`charts/backstage/files/lightspeed/secret.yaml\`
> [!CAUTION]
> Please review the upstream changes carefully before merging.
EOF
)
gh pr create \
--title "${TITLE}" \
--body "${BODY}" \
--base "${TARGET_BRANCH}"
fi