Skip to content

Commit 84e79d2

Browse files
authored
Create bedrock_updater.yml
1 parent 819cc51 commit 84e79d2

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Bedrock Download URLs Updater
2+
3+
on:
4+
schedule:
5+
- cron: '0 0/1 * * *' # Runs every hour
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-bedrock-urls:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout AMPTemplates repository
17+
uses: actions/checkout@v4
18+
path: AMPTemplates
19+
20+
- name: Install Puppeteer dependencies
21+
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
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
28+
- name: Install puppeteer and extra packages
29+
run: npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
30+
31+
- name: Fetch current Bedrock download URLs
32+
run: |
33+
node AMPTemplates/scripts/get_bedrock_download_urls.mjs
34+
echo "currentDownloadURLs=$(jq -c '.' bedrock-urls.json)" >> $GITHUB_ENV
35+
36+
- name: Read last known URLs
37+
working-directory: AMPTemplates
38+
run: |
39+
lastDownloadURLs=$(jq -c '.' minecraft-bedrockdownloadurl.json)
40+
echo "lastDownloadURLs=$lastDownloadURLs" >> $GITHUB_ENV
41+
42+
- name: Check for updates
43+
id: check_updates
44+
run: |
45+
if [[ "$currentDownloadURLs" != "$lastDownloadURLs" ]]; then
46+
echo "update_needed=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "update_needed=false" >> $GITHUB_OUTPUT
49+
fi
50+
51+
- name: Configure Git
52+
if: steps.check_updates.outputs.update_needed == 'true'
53+
run: |
54+
git config --global user.name 'github-actions[bot]'
55+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
56+
57+
- name: Update minecraft-bedrockdownloadurl.json
58+
if: steps.check_updates.outputs.update_needed == 'true'
59+
working-directory: AMPTemplates
60+
run: |
61+
echo "$currentDownloadURLs" | jq --indent 4 '.' > minecraft-bedrockdownloadurl.json
62+
git add minecraft-bedrockdownloadurl.json
63+
if git diff-index --quiet HEAD --; then
64+
echo "No changes to commit"
65+
else
66+
git commit -m "Update Bedrock download URLs"
67+
git push
68+
fi

0 commit comments

Comments
 (0)