Fetch Prometheus Grafana Versions #46
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: Fetch Prometheus Grafana Versions | |
on: | |
schedule: | |
- cron: '0 0 1 * *' # Runs at 00:00, on day 1 of each month | |
jobs: | |
fetch_promgraf_versions: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Fetch Latest Prometheus Version | |
run: | | |
PROM_V_LATEST_VERSION=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') | |
PROM_LATEST_VERSION=$(echo "${PROM_V_LATEST_VERSION}" | cut -c 2-) | |
echo "Latest Prometheus Version: ${PROM_LATEST_VERSION}" | |
sed -i " 4 c LATEST_VERSION=${PROM_LATEST_VERSION} " amazonlinux-prometheus.sh | |
sed -i " 4 c LATEST_VERSION=${PROM_LATEST_VERSION} " ubuntu-prometheus.sh | |
- name: Commit updated prometheus versions | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "actions@github.com" | |
git add amazonlinux-prometheus.sh | |
git add ubuntu-prometheus.sh | |
if ! git diff --cached --quiet; then | |
echo "Promethus version differs, updating 2 promethus files..." | |
git commit -m "Update Promethus.sh file" | |
git push | |
else | |
echo "No changes detected, skipping commit." | |
fi | |
- name: Fetch Latest Grafana Version | |
run: | | |
GRAF_V_LATEST_VERSION=$(curl -s https://api.github.com/repos/grafana/grafana/releases/latest | jq -r '.tag_name') | |
GRAF_LATEST_VERSION=$(echo "${GRAF_V_LATEST_VERSION}" | cut -c 2-) | |
echo "Latest Grafana Version: ${GRAF_LATEST_VERSION}" | |
sed -i " 5 c LATEST_VERSION=${GRAF_LATEST_VERSION} " amazonlinux-grafana.sh | |
sed -i " 5 c LATEST_VERSION=${GRAF_LATEST_VERSION} " ubuntu-grafana.sh | |
- name: Commit updated grafana versions | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "actions@github.com" | |
git add amazonlinux-grafana.sh | |
git add ubuntu-grafana.sh | |
if ! git diff --cached --quiet; then | |
echo "Grafana version differs, updating 2 gragana files..." | |
git commit -m "Update Grafana.sh file" | |
git push | |
else | |
echo "No changes detected, skipping commit." | |
fi | |
- name: Fetch Latest Note Exporter Version | |
run: | | |
latest_version=$(curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') | |
node_latest_version=$(echo "${latest_version}" | cut -c 2-) | |
echo "Fetched Latest Node Exporter Version: ${node_latest_version}" | |
sed -i " 4 c LATEST_VERSION=${node_latest_version}" amazonlinux-nodexporter.sh | |
sed -i " 4 c LATEST_VERSION=${node_latest_version}" ubuntu-nodexporter.sh | |
- name: Commit updated node exporter versions | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "actions@github.com" | |
git add amazonlinux-nodexporter.sh | |
git add ubuntu-nodexporter.sh | |
if ! git diff --cached --quiet; then | |
echo "Node Exporter version differs, updating 3 node_exporter files..." | |
git commit -m "Update Node_Exporter.sh file" | |
git push | |
else | |
echo "No changes detected, skipping commit." | |
fi |