Sync Lightspeed Core Configs #128
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Lightspeed Core Configs | |
| on: | |
| schedule: | |
| - cron: '0 4 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| sync-lightspeed: | |
| name: Sync Lightspeed Core 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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| fetch-depth: 0 | |
| - name: Resolve vendored config paths | |
| id: paths | |
| run: | | |
| # Scheduled workflows run from the default branch YAML, then check out | |
| # matrix.branch. Only release-1.10 still vendors Lightspeed under the | |
| # backstage chart; main and later release branches use rhdh. | |
| BRANCH="${{ matrix.branch }}" | |
| if [[ "${BRANCH}" == "release-1.10" ]]; then | |
| FILES_DIR="charts/backstage/files/lightspeed" | |
| CHART_YAML="charts/backstage/Chart.yaml" | |
| else | |
| FILES_DIR="charts/rhdh/files/intelligent-assistant" | |
| CHART_YAML="charts/rhdh/Chart.yaml" | |
| fi | |
| echo "files_dir=${FILES_DIR}" >> "$GITHUB_OUTPUT" | |
| echo "chart_yaml=${CHART_YAML}" >> "$GITHUB_OUTPUT" | |
| echo "Using ${FILES_DIR} and ${CHART_YAML} for ${BRANCH}" | |
| - name: Set up Helm | |
| uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 | |
| with: | |
| version: v3.21.4 | |
| - name: Set up yq | |
| uses: mikefarah/yq@c14f446382944492701b16c1ddb48bb9dbe683e3 # v4.53.6 | |
| with: | |
| cmd: yq --version | |
| - name: Set up Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 | |
| 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 Core config files | |
| run: | | |
| if [[ "${{ matrix.branch }}" == "release-1.10" ]]; then | |
| ./hack/sync-lightspeed-configs.sh --repo redhat-ai-dev/lightspeed-configs --ref ${{ matrix.branch }} | |
| else | |
| ./hack/sync-lightspeed-configs.sh --ref ${{ matrix.branch }} | |
| fi | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet "${{ steps.paths.outputs.files_dir }}"; 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@c14f446382944492701b16c1ddb48bb9dbe683e3 # v4.53.6 | |
| with: | |
| cmd: yq '.version' "${{ steps.paths.outputs.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@c14f446382944492701b16c1ddb48bb9dbe683e3 # v4.53.6 | |
| with: | |
| cmd: yq -i '.version = "${{ steps.semver.outputs.new_version }}"' "${{ steps.paths.outputs.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 }} | |
| FILES_DIR: ${{ steps.paths.outputs.files_dir }} | |
| run: | | |
| TITLE="chore(intelligent-assistant): sync Lightspeed Core config files and bump chart to ${NEW_VERSION}" | |
| 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" | |
| 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}" | |
| SYNCED_FILES=$(git diff --name-only HEAD~1 -- "${FILES_DIR}" | sed 's/^/- `/;s/$/`/') | |
| BODY=$(cat <<EOF | |
| Automated nightly sync of Lightspeed Core config files from [${TARGET_REPO} @ ${TARGET_BRANCH}](https://github.com/${TARGET_REPO}/tree/${TARGET_BRANCH}). | |
| Bumped chart version to **${NEW_VERSION}**. | |
| ### 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 |