Repository navigation
127 lines (104 loc) · 4.26 KB
/
Copy pathsync-lightspeed-configs.yaml
File metadata and controls
127 lines (104 loc) · 4.26 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
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
- release-2.1
concurrency:
group: ${{ github.workflow }}-${{ matrix.branch }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: 'go.mod'
- name: Set up yq
uses: mikefarah/yq@c14f446382944492701b16c1ddb48bb9dbe683e3 # v4.53.6
with:
cmd: yq --version
- 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 Core config files and check for changes
id: changes
run: |
./hack/sync-lightspeed-configs.sh --ref ${{ matrix.branch }}
if [[ "${{ matrix.branch }}" == "release-1.10" ]]; then
CHANGE_PATHS=(config/profile/rhdh/default-config/flavours/lightspeed/ examples/lightspeed.yaml)
else
CHANGE_PATHS=(config/profile/rhdh/default-config/flavours/intelligent-assistant/ config/profile/rhdh/default-config/flavours/intelligent-assistant-okp/ examples/intelligent-assistant.yaml)
fi
if git diff --quiet -- "${CHANGE_PATHS[@]}"; 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: Regenerate manifests
if: steps.changes.outputs.has_changes == 'true'
run: make bundles build-installers
- name: Commit changes and open PR
if: steps.changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_BRANCH: ${{ matrix.branch }}
run: |
TITLE="chore(lightspeed): sync config files from upstream"
BRANCH="chore/sync-lightspeed-configs-${TARGET_BRANCH}"
TARGET_REPO="redhat-developer/rhdh-intelligent-assistant-configs"
if [[ "${TARGET_BRANCH}" == "release-1.10" ]]; then
TARGET_REPO="redhat-ai-dev/lightspeed-configs"
SYNCED_FILES=$(printf '%s\n' \
'- `config/profile/rhdh/default-config/flavours/lightspeed/configmap-files.yaml`' \
'- `examples/lightspeed.yaml`')
else
SYNCED_FILES=$(printf '%s\n' \
'- `config/profile/rhdh/default-config/flavours/intelligent-assistant/configmap-files.yaml`' \
'- `config/profile/rhdh/default-config/flavours/intelligent-assistant-okp/configmap-files.yaml`' \
'- `examples/intelligent-assistant.yaml`')
fi
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 Core config files from [${TARGET_REPO} @ ${TARGET_BRANCH}](https://github.com/${TARGET_REPO}/tree/${TARGET_BRANCH}).
### Synced files
${SYNCED_FILES}
> [!CAUTION]
> Please review the upstream changes carefully before merging.
EOF
)
gh pr create \
--title "${TITLE}" \
--body "${BODY}" \
--base "${TARGET_BRANCH}"
fi