Skip to content

Bedrock Download URLs Updater #8

Bedrock Download URLs Updater

Bedrock Download URLs Updater #8

name: Bedrock Download URLs Updater
on:
schedule:
- cron: '0 0/1 * * *' # Runs every hour
workflow_dispatch:
jobs:
check-bedrock-urls:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout AMPTemplates repository
uses: actions/checkout@v4
with:
path: AMPTemplates
- name: Install Puppeteer dependencies
run: sudo apt-get update && sudo apt-get install -y libnss3 libatk-bridge2.0-0 libxss1 libasound2t64 libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libgtk-3-0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install puppeteer and extra packages
run: npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
- name: Fetch current Bedrock download URLs
run: |
node AMPTemplates/scripts/get_bedrock_download_urls.mjs
echo "currentDownloadURLs=$(jq -c '.' bedrock-urls.json)" >> $GITHUB_ENV
- name: Read last known URLs
working-directory: AMPTemplates
run: |
lastDownloadURLs=$(jq -c '.' minecraft-bedrockdownloadurl.json)
echo "lastDownloadURLs=$lastDownloadURLs" >> $GITHUB_ENV
- name: Check for updates
id: check_updates
run: |
if [[ "$currentDownloadURLs" != "$lastDownloadURLs" ]]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
else
echo "update_needed=false" >> $GITHUB_OUTPUT
fi
- name: Configure Git
if: steps.check_updates.outputs.update_needed == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Update minecraft-bedrockdownloadurl.json
if: steps.check_updates.outputs.update_needed == 'true'
working-directory: AMPTemplates
run: |
echo "$currentDownloadURLs" | jq --indent 4 '.' > minecraft-bedrockdownloadurl.json
git add minecraft-bedrockdownloadurl.json
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "Update Bedrock download URLs"
git push
fi