mirror of
https://github.com/Nostalgica-Reverie/Content-Monorepo.git
synced 2026-05-09 00:24:15 +00:00
fix(auto-update): upload to the right dir
This commit is contained in:
78
.github/workflows/auto-update.yml
vendored
78
.github/workflows/auto-update.yml
vendored
@@ -18,8 +18,22 @@ jobs:
|
||||
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:
|
||||
@@ -30,52 +44,44 @@ jobs:
|
||||
|
||||
# Only set up Go and install Packwiz if not cached
|
||||
- name: Set up Go
|
||||
if: steps.cache-packwiz.outputs.cache-hit != 'true'
|
||||
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.cache-packwiz.outputs.cache-hit != 'true'
|
||||
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 }}"
|
||||
if [ -d "$DIR" ]; then
|
||||
echo "Updating ${{ matrix.modpack }} ${{ matrix.platform }} ${{ matrix.loader }} ${{ matrix.minecraft }}"
|
||||
cd "$DIR"
|
||||
packwiz refresh -y
|
||||
packwiz update -a -y
|
||||
else
|
||||
echo "Directory $DIR does not exist, skipping"
|
||||
fi
|
||||
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
|
||||
run: sleep 5
|
||||
if: steps.check-dir.outputs.dir-exists == 'true'
|
||||
run: sleep 10
|
||||
|
||||
# Check if there are changes and upload them
|
||||
- name: Check for changes
|
||||
id: check-changes
|
||||
run: |
|
||||
if git diff --quiet; then
|
||||
echo "has-changes=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "has-changes=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Upload the entire workspace if there are changes
|
||||
# Upload changes only if files were updated
|
||||
- name: Upload changes
|
||||
if: steps.check-changes.outputs.has-changes == 'true'
|
||||
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/
|
||||
path: ./versions/vanilla/src/${{ matrix.modpack }}/${{ matrix.platform }}/${{ matrix.loader }}/${{ matrix.minecraft }}/
|
||||
retention-days: 1
|
||||
|
||||
commit-changes:
|
||||
@@ -93,8 +99,30 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: changes-*
|
||||
merge-multiple: true
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user