Skip to content

Fetch Minecraft Server Version #159

Fetch Minecraft Server Version

Fetch Minecraft Server Version #159

name: Fetch Minecraft Server Version
# This workflow is triggered daily and can also be manually triggered
on:
push:
paths:
- '.github/workflows/fetch-minecraft-version.yml'
schedule:
- cron: '0 0 * * *' # Scheduled to run every day at midnight
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
fetch-version:
runs-on: ubuntu-latest
steps:
# Checkout the code from the GitHub repository
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
# Setup Python environment
- name: Setup Python Environment
uses: actions/setup-python@v4
with:
python-version: 3.11
# Install Chromium and necessary dependencies
- name: Install Chromium and Dependencies
run: |
sudo apt purge --remove google-chrome-stable -y
sudo apt purge --remove chromium-browser -y
sudo apt autoremove && sudo apt autoclean -y
sudo rm -rf /usr/bin/chromium
sudo apt install chromium-browser -y
chromium-browser --product-version
pip install selenium
# Execute Python script to fetch the latest Minecraft server version
- name: Fetch Minecraft Server Version
run: |
python scripts/fetch_version.py | while IFS='=' read -r key value; do
if [ -n "$key" ] && [ -n "$value" ]; then
echo "$key=$value" >> $GITHUB_ENV
fi
done
# Store the fetched stable version and commit the changes to the repository
- name: Store Fetched Stable Version
run: |
echo $STABLE_VERSION > versions/stable.txt
- name: Commit and Push Stable Changes
uses: EndBug/add-and-commit@v9
with:
add: 'versions/stable.txt'
message: "Update stable version"
default_author: github_actions
# Store the fetched preview version and commit the changes to the repository
- name: Store Fetched Preview Version
run: |
echo $PREVIEW_VERSION > versions/preview.txt
- name: Commit and Push Preview Changes
uses: EndBug/add-and-commit@v9
with:
add: 'versions/preview.txt'
message: "Update preview version"
default_author: github_actions