Skip to content

fetch-pgm-maps

fetch-pgm-maps #49

name: fetch-pgm-maps
on:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
jobs:
fetch-pgm-maps:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
- name: checkout map fetcher
uses: actions/checkout@v3
with:
repository: MCResourcePile/map-fetcher
path: "./map-fetcher"
- name: install dependencies
run: |
cd ./map-fetcher
npm install
- name: execute script
run: |
cd ./map-fetcher
node src/index.js --output="../src/data/maps/pgm.json"
# - name: download minecraft textures
# run: |
# VERSION=1.16.1
# mkdir -p ~/.minecraft/versions/${VERSION}/
# wget https://overviewer.org/textures/${VERSION} -O ~/.minecraft/versions/${VERSION}/${VERSION}.jar
#
# - name: download jmc2obj
# run: |
# wget https://github.com/jmc2obj/j-mc-2-obj/releases/download/120/jMc2Obj-120.jar -O ./map-fetcher/jmc2obj.jar
#
# - name: checkout 3d map objects
# uses: actions/checkout@v3
# with:
# repository: MCResourcePile/mcresourcepile.github.io
# ref: "3d-objects"
# path: "./map-fetcher/objects"
#
# - name: execute jmc2obj
# run: |
# cd ./map-fetcher
# for k in $(jq '.data.maps | keys | .[]' pgm.json | tr -d '\r'); do
# value=$(jq -r ".data.maps[$k]" pgm.json | tr -d '\r');
# mapid=$(jq -r '.id' <<< "$value");
# version=$(jq -r '.version' <<< "$value");
# outputpath="objects/maps/${mapid}_${version}"
#
# echo $mapid
#
# if [ ! -d "${outputpath}" ]
# then
# minx=$(jq -r '.regions.x.min' <<< "$value");
# maxx=$(jq -r '.regions.x.max' <<< "$value");
# minz=$(jq -r '.regions.z.min' <<< "$value");
# maxz=$(jq -r '.regions.z.max' <<< "$value");
# sourcemaintainer=$(jq -r '.source.maintainer' <<< "$value");
# sourcerepository=$(jq -r '.source.repository' <<< "$value");
# sourcepath=$(jq -r '.source.path' <<< "$value");
# targetpath="${sourcemaintainer}/${sourcerepository}/${sourcepath}"
#
# mkdir -p "${outputpath}"
# java -jar jmc2obj.jar -c="${minx},${minz},${maxx},${maxz}" -s -o="${outputpath}" "${targetpath}"
# sed -r -i 's/map_d [a-z/_.]+/d 0.99/g' "${targetpath}/minecraft.mtl"
# fi
# done
#
# - name: commit map objects
# uses: JamesIves/[email protected]
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BASE_BRANCH: source
# BRANCH: "3d-objects"
# FOLDER: "map-fetcher/objects"
# CLEAN: true
# GIT_CONFIG_EMAIL: [email protected]
# COMMIT_MESSAGE: Upload PGM map 3D objects
- name: remove temp files
run: |
rm -r ./map-fetcher
- name: commit changes
if: github.event_name != 'pull_request'
uses: EndBug/add-and-commit@v9
with:
message: Update PGM maps data file
- uses: actions/upload-artifact@v3
with:
name: pgm.json
path: ./src/data/maps/pgm.json
- name: trigger page rebuild
uses: peter-evans/repository-dispatch@v2
with:
event-type: run_build