Skip to content

Fetch Minecraft Server Version #262

Fetch Minecraft Server Version

Fetch Minecraft Server Version #262

name: Fetch Minecraft Server Version ๐ŸŽฎ
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
# Setup Python environment
- name: Setup Python Environment ๐Ÿ
uses: actions/setup-python@v4
with:
python-version: 3.11
# Cache pip dependencies
- name: Cache pip ๐Ÿ“ฆ
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Install dependencies
- name: Install 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
# Create versions directory if it doesn't exist
- name: Create Versions Directory ๐Ÿ“
run: mkdir -p versions
# 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 and Commit Fetched Versions ๐Ÿ“‚
run: |
echo $STABLE_VERSION > versions/stable.txt
echo $PREVIEW_VERSION > versions/preview.txt
git config --global user.name "github_actions"
git config --global user.email "github_actions@github.com"
git add versions/stable.txt versions/preview.txt
git commit -m "โฌ†๏ธ Update stable and preview versions"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}