mirror of
https://github.com/Nostalgica-Reverie/Content-Monorepo.git
synced 2026-05-09 00:24:15 +00:00
130 lines
4.8 KiB
YAML
130 lines
4.8 KiB
YAML
name: Auto Update
|
|
on:
|
|
workflow_dispatch:
|
|
jobs:
|
|
update-modpacks:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
modpack: [re-console, re-console-lite]
|
|
platform: [curseforge, modrinth]
|
|
loader: [fabric]
|
|
minecraft: [1.20.1, 1.20.4, 1.21.1, 1.21.3, 1.21.4, 1.21.5, 1.21.8]
|
|
max-parallel: 3 # Helps with rate limiting
|
|
fail-fast: false
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GH_PAT }}
|
|
fetch-depth: 1
|
|
|
|
# Check if directory exists first
|
|
- name: Check if directory exists
|
|
id: check-dir
|
|
run: |
|
|
DIR="./versions/vanilla/src/${{ matrix.modpack }}/${{ matrix.platform }}/${{ matrix.loader }}/${{ matrix.minecraft }}"
|
|
if [ -d "$DIR" ]; then
|
|
echo "dir-exists=true" >> $GITHUB_OUTPUT
|
|
echo "Directory $DIR exists, proceeding with update"
|
|
else
|
|
echo "dir-exists=false" >> $GITHUB_OUTPUT
|
|
echo "Directory $DIR does not exist, skipping all steps"
|
|
fi
|
|
|
|
# Cache Packwiz binary to avoid Go setup and compilation
|
|
- name: Cache Packwiz Binary
|
|
if: steps.check-dir.outputs.dir-exists == 'true'
|
|
uses: actions/cache@v4
|
|
id: cache-packwiz
|
|
with:
|
|
path: ~/go/bin/packwiz
|
|
key: packwiz-binary-${{ runner.os }}-v1
|
|
restore-keys: |
|
|
packwiz-binary-${{ runner.os }}-
|
|
|
|
# Only set up Go and install Packwiz if not cached
|
|
- name: Set up Go
|
|
if: steps.check-dir.outputs.dir-exists == 'true' && steps.cache-packwiz.outputs.cache-hit != 'true'
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 'stable'
|
|
cache: false
|
|
|
|
- name: Install Packwiz
|
|
if: steps.check-dir.outputs.dir-exists == 'true' && steps.cache-packwiz.outputs.cache-hit != 'true'
|
|
run: go install github.com/packwiz/packwiz@latest
|
|
|
|
# Add Packwiz to PATH (whether cached or freshly installed)
|
|
- name: Add Packwiz to PATH
|
|
if: steps.check-dir.outputs.dir-exists == 'true'
|
|
run: echo "$HOME/go/bin" >> $GITHUB_PATH
|
|
|
|
- name: Update ${{ matrix.modpack }} - ${{ matrix.platform }} - ${{ matrix.loader }} - ${{ matrix.minecraft }}
|
|
if: steps.check-dir.outputs.dir-exists == 'true'
|
|
id: update-step
|
|
run: |
|
|
DIR="./versions/vanilla/src/${{ matrix.modpack }}/${{ matrix.platform }}/${{ matrix.loader }}/${{ matrix.minecraft }}"
|
|
echo "Updating ${{ matrix.modpack }} ${{ matrix.platform }} ${{ matrix.loader }} ${{ matrix.minecraft }}"
|
|
cd "$DIR"
|
|
packwiz refresh -y
|
|
UPDATE_OUTPUT=$(packwiz update -a -y 2>&1 | tail -n 1)
|
|
echo "update-output=$UPDATE_OUTPUT" >> $GITHUB_OUTPUT
|
|
echo "Last line of packwiz update: $UPDATE_OUTPUT"
|
|
|
|
- name: Rate limiting delay
|
|
if: steps.check-dir.outputs.dir-exists == 'true'
|
|
run: sleep 5
|
|
|
|
# Upload changes only if files were updated
|
|
- name: Upload changes
|
|
if: steps.check-dir.outputs.dir-exists == 'true' && steps.update-step.outputs.update-output == 'Files updated!'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: changes-${{ strategy.job-index }}
|
|
path: ./versions/vanilla/src/${{ matrix.modpack }}/${{ matrix.platform }}/${{ matrix.loader }}/${{ matrix.minecraft }}/
|
|
retention-days: 1
|
|
|
|
commit-changes:
|
|
needs: update-modpacks
|
|
runs-on: ubuntu-22.04
|
|
if: always() # Run even if some matrix jobs fail
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GH_PAT }}
|
|
fetch-depth: 1
|
|
|
|
# Download all artifacts from matrix jobs
|
|
- name: Download all changes
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: changes-*
|
|
path: ./
|
|
merge-multiple: false
|
|
|
|
# Move artifacts to correct locations
|
|
- name: Restore file structure
|
|
run: |
|
|
if [ -d "./changes-"* ]; then
|
|
for artifact_dir in ./changes-*; do
|
|
if [ -d "$artifact_dir" ]; then
|
|
echo "Processing $artifact_dir"
|
|
# Find and move the content to the right location
|
|
find "$artifact_dir" -name "versions" -type d | while read versions_dir; do
|
|
if [ -d "$versions_dir" ]; then
|
|
echo "Copying from $versions_dir to ./versions/"
|
|
cp -r "$versions_dir"/* ./versions/ 2>/dev/null || true
|
|
fi
|
|
done
|
|
# Clean up artifact directory
|
|
rm -rf "$artifact_dir"
|
|
fi
|
|
done
|
|
else
|
|
echo "No artifacts found to process"
|
|
fi
|
|
|
|
- name: Commit Updates
|
|
uses: EndBug/add-and-commit@v9.1.4
|
|
with:
|
|
default_author: github_actions |