Skip to content

Commit

Permalink
Automate Orcsoberfest/Percht Island updates
Browse files Browse the repository at this point in the history
Closes #104.
  • Loading branch information
mathiasbynens committed Oct 20, 2020
1 parent fc3dda0 commit 0f7c83e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/enable-orcsoberfest-island-pack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Enable Orcsoberfest Island pack'

on:
schedule:
# Run annually at 04:00 UTC on February 1st.
- cron: '0 4 1 2 *'
workflow_dispatch:

jobs:
import-markers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Install dependencies
run: npm install
- name: Enable pack
run: |
scripts/enable-pack.sh orcsoberfest
git config user.name 'Mathias Bynens'
git config user.email '[email protected]'
git commit data/markers.json -m 'Enable Orcsoberfest Island maps' -m 'This patch replaces the Percht Island maps (and their markers) with the Orcsoberfest Island maps (and their markers) in preparation for the upcoming event.'
git push
25 changes: 25 additions & 0 deletions .github/workflows/enable-percht-island.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Enable Percht Island pack'

on:
schedule:
# Run annually at 04:00 UTC on December 1st.
- cron: '0 4 1 12 *'
workflow_dispatch:

jobs:
import-markers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Install dependencies
run: npm install
- name: Enable pack
run: |
scripts/enable-pack.sh percht
git config user.name 'Mathias Bynens'
git config user.email '[email protected]'
git commit data/markers.json -m 'Enable Percht Island maps' -m 'This patch replaces the Orcsoberfest Island maps (and their markers) with the Percht Island maps (and their markers) in preparation for the upcoming event.'
git push
4 changes: 2 additions & 2 deletions scripts/enable-marker-pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const sortMarkers = require('tibia-maps/src/sort-markers.js');
const arg = process.argv[2];

const map = new Map([
['percht', { old: 'percht-island', new: 'orcsoberfest-island' }],
['orcsoberfest', { old: 'orcsoberfest-island', new: 'percht-island' }],
['percht', { old: 'orcsoberfest-island', new: 'percht-island' }],
['orcsoberfest', { old: 'percht-island', new: 'orcsoberfest-island' }],
]);
const config = map.get(arg);
const isSpecialCase = Boolean(config);
Expand Down
9 changes: 6 additions & 3 deletions scripts/enable-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# Navigate to the root of the repository.
cd "$(dirname "${BASH_SOURCE}")/..";

# Ensure `tibia-maps` is in the PATH on CI.
PATH="${PATH}:$(pwd)/node_modules/.bin";

if [ -z "${1}" ]; then
echo 'No argument supplied. Example usage:';
echo '';
echo './scripts/enable-pack.sh orcsoberfest';
echo './scripts/enable-pack.sh percht';
echo 'scripts/enable-pack.sh orcsoberfest';
echo 'scripts/enable-pack.sh percht';
exit 0;
fi;

Expand All @@ -20,7 +23,7 @@ echo 'Generating minimap files…';
tibia-maps --from-data=data --output-dir=minimap;
echo "Merging minimap files from the \`${1}-island\` pack…";
cp -f extra/"${1}"-island/*.png minimap;
echo 'Converting updated minimap back to \`data/*\`…';
echo 'Converting updated minimap back to `data/*`…';
tibia-maps --from-minimap=./minimap --output-dir=./data;
echo 'Updating markers…';
node scripts/enable-marker-pack.js "${1}";

0 comments on commit 0f7c83e

Please sign in to comment.