Skip to content
Open
Changes from 1 commit
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
66 changes: 66 additions & 0 deletions .github/workflows/website-release-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Check and Update Release Version in Website Repository

on:
schedule:
- cron: '0 12 * * *' #Every day 12:00

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 $JSON_FILE"
git push origin update-version

- name: Create Pull Request
if: env.update_needed == 'true'
uses: rhobs/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: 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 }}"