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
60 changes: 60 additions & 0 deletions .github/workflows/website-release-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Check and Update Release Version

on:
workflow_dispatch:
schedule:
- cron: '11 5 * * *' #Every day 05:11AM UTC

jobs:
check-and-update-release-version:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Get latest release tag from prometheus-operator repository
id: get_latest_release
run: |
LATEST_RELEASE=$(curl --fail --silent "https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest" | jq -r '.tag_name')
if [ "$LATEST_RELEASE" == "" ]; then
echo "latest-release is invalid" >> "$GITHUB_OUTPUT"
exit 1
fi
echo "latest-release = $LATEST_RELEASE" >> "$GITHUB_OUTPUT"
- name: Check version in website repository
run: |
JSON_FILE="data/prometheusOperator.json"
CURRENT_VERSION=$(jq -r '.version' $JSON_FILE)
echo "Current version: $CURRENT_VERSION"

if [ "$CURRENT_VERSION" == "${{ steps.get_latest_release.outputs.latest_release }}" ]; then
echo "Latest version. No updates needed"
echo "update_needed=false" >> "$GITHUB_ENV"
else
echo "Versions do not match. An update is required."
echo "update_needed=true" >> "$GITHUB_ENV"
fi
- name: Update version
if: env.update_needed == 'true'
run: |
JSON_FILE="data/prometheusOperator.json"
NEW_VERSION="${{steps.get_latest_release.outputs.latest_release}}"

jq -i --arg version "$NEW_VERSION" '.version = $version' $JSON_FILE

git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

git checkout -b update-version
git add $JSON_FILE
git commit -m "chore: bump to $NEW_VERSION"
git push origin update-version
- name: Create Pull Request
if: env.update_needed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: test-wrokflow #Testing in this branch before making changes to main
head: update-version
title: "chore: bump to ${{ steps.get_latest_release.outputs.latest_release }}"
body: "This PR updates the release version in prometheusOperator.json file to the latest version: ${{ steps.get_latest_release.outputs.latest_release }} "