Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/workflows/update-ui-plugin-charts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Update UI Plugin Charts Manifest

on:
release:
types: [published]

jobs:
update-manifest:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract version from release
id: extract_version
run: |
# Extract version from release tag (e.g., v1.6.0 -> 1.6.0)
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Extracted version: ${VERSION}"

- name: Checkout ui-plugin-charts repository
uses: actions/checkout@v4
with:
repository: rancher/ui-plugin-charts
token: ${{ secrets.ACCESS_UI_CHARTS_SECRET }}
path: ui-plugin-charts

- name: Create branch for release
run: |
cd ui-plugin-charts
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
BRANCH_NAME="release-harv-${{ steps.extract_version.outputs.version }}"
git checkout -b "$BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV

- name: Update manifest.json
run: |
cd ui-plugin-charts

# Read current manifest
MANIFEST=$(cat manifest.json)

# Extract current harvester versions
CURRENT_VERSIONS=$(echo "$MANIFEST" | jq -r '.extensions.harvester.versions[]')

# Check if version already exists
if echo "$CURRENT_VERSIONS" | grep -q "^${{ steps.extract_version.outputs.version }}$"; then
echo "Version ${{ steps.extract_version.outputs.version }} already exists in manifest.json"
exit 0
fi

# Add new version to the list and sort
UPDATED_VERSIONS=$(echo "$CURRENT_VERSIONS"$'\n'"${{ steps.extract_version.outputs.version }}" | sort -V)

# Convert back to JSON array
VERSIONS_JSON=$(echo "$UPDATED_VERSIONS" | jq -R . | jq -s .)

# Update manifest.json
echo "$MANIFEST" | jq --argjson versions "$VERSIONS_JSON" '.extensions.harvester.versions = $versions' > manifest.json.tmp
mv manifest.json.tmp manifest.json

echo "Updated manifest.json with version ${{ steps.extract_version.outputs.version }}"

- name: Commit and push changes
run: |
cd ui-plugin-charts
git add manifest.json
git commit -m "release harvester-ui-extension ${{ steps.extract_version.outputs.version }}"
git push origin "$BRANCH_NAME"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.ACCESS_UI_CHARTS_SECRET }}
path: ui-plugin-charts
branch: ${{ env.BRANCH_NAME }}
title: "release harvester-ui-extension ${{ steps.extract_version.outputs.version }}"
body: |
This PR adds Harvester UI Extension version ${{ steps.extract_version.outputs.version }} to the manifest.json file.

**Changes:**
- Added version `${{ steps.extract_version.outputs.version }}` to the Harvester extension versions list

**Release:** ${{ github.event.release.html_url }}

**Auto-generated by:** ${{ github.workflow }}
base: main
reviewers: |
aalves08
nwmac