Fetch Minecraft Server Version #262
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 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 }} |