Check prometheus-exporter-plugin-for-opensearch #393
This file contains 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: Check prometheus-exporter-plugin-for-opensearch | |
on: | |
schedule: | |
- cron: "0 7 * * *" | |
workflow_dispatch: | |
jobs: | |
check-for-updates: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- branch: 'main' | |
majorversion: '2.' | |
- branch: '1.x' | |
majorversion: '1.' | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{matrix.branch}} | |
- name: Check for updates | |
id: update | |
run: | | |
# ###################################################################### | |
# This updater checks the exporter plugin version first since this build | |
# depends on the plugin. The plugin and the application follows the same | |
# versioning. | |
# ###################################################################### | |
# | |
# Lock to a major version | |
# | |
majorversion=${{matrix.majorversion}} | |
# | |
# Fetch the latest tag - filtered on majorversion | |
# | |
releases="https://api.github.com/repos/aiven/prometheus-exporter-plugin-for-opensearch/releases" | |
latest=$(curl --location --silent ${releases} | \ | |
jq -r 'map(select(.tag_name|startswith("'${majorversion}'")))[0]') | |
# | |
# Extract the plugin version / tag_name | |
# | |
pluginversion=$(echo $latest | jq -r '.tag_name') | |
# The Application follows semver, so only keep x.y.z | |
version=$(echo ${pluginversion} | cut -d. -f 1-3) | |
# | |
# Extract the download URL to use in the Dockerfile | |
# | |
browser_download_url=$(echo $latest | jq -r '.assets[0].browser_download_url') | |
echo version=${version} >> $GITHUB_OUTPUT | |
echo pluginversion=${pluginversion} >> $GITHUB_OUTPUT | |
echo branch=${{matrix.branch}} >> $GITHUB_OUTPUT | |
if [[ "${version}XX" = ${majorversion}*XX ]];then | |
# | |
# Patch the Dockerfile | |
# Bump opensearch and the plugin to the same version | |
# | |
sed -i -r \ | |
-e "s|^(\s*FROM [^/]+/opensearch)\s*:.*|\1:${version}|" \ | |
-e "s|^(ARG EXPORTER_PLUGIN_URL)\s*=.*|\1=\"${browser_download_url}\"|" \ | |
Dockerfile | |
fi | |
- name: Create PR | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
base: ${{ steps.update.outputs.branch }} | |
branch: "opensearch-exporter/bump-${{ steps.update.outputs.version }}" | |
title: "Bump to opensearch-${{ steps.update.outputs.version }} with prometheus-exporter-plugin-for-opensearch-${{ steps.update.outputs.pluginversion }}" | |
commit-message: "Bump to opensearch-${{ steps.update.outputs.version }} with prometheus-exporter-plugin-for-opensearch-${{ steps.update.outputs.pluginversion }}" | |
labels: | | |
dependencies | |
reviewers: DShivakoti | |
#team-reviewers: | | |
# devtools | |
draft: False |