Skip to content

Commit 45b8137

Browse files
committed
Upload new map and wam associate
1 parent 390e138 commit 45b8137

28 files changed

+12629
-4312
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,93 @@
1-
name: Optimize map and deploy
1+
name: Build and deploy
22

3-
on: [ push ]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch: # allow manual execution
48

59
permissions:
610
contents: write
711
pages: write
812
actions: write
913

1014
jobs:
11-
deploy:
15+
build-and-deploy:
1216
runs-on: ubuntu-latest
1317

1418
steps:
15-
- name: Checkout
19+
- name: Checkout Repository
1620
uses: actions/checkout@v3
1721

18-
- uses: actions/setup-node@v3
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v3
1924
with:
20-
node-version: '16.x'
21-
registry-url: 'https://registry.npmjs.org'
25+
node-version: "18.x"
26+
registry-url: "https://registry.npmjs.org"
2227

23-
- name: "Install dependencies"
28+
- name: Install Dependencies
2429
run: npm install
2530

26-
- name: "Build scripts"
31+
- name: Build project
2732
run: npm run build
2833

29-
- name: Deploy
34+
- name: Extract UPLOAD_MODE from .env
35+
run: |
36+
UPLOAD_MODE=$(grep '^[^#]*UPLOAD_MODE' .env | cut -d '=' -f2)
37+
if [ -z "$UPLOAD_MODE" ]; then
38+
echo "Error: UPLOAD_MODE is not set in .env."
39+
exit 1
40+
fi
41+
echo "UPLOAD_MODE=$UPLOAD_MODE" >> $GITHUB_ENV
42+
43+
- name: Set up Environment Variables
44+
if: ${{ env.UPLOAD_MODE == 'MAP_STORAGE' }}
45+
run: |
46+
# MAP_STORAGE_API_KEY must always come from GitHub Secrets in CI
47+
if [ -z "${{ secrets.MAP_STORAGE_API_KEY }}" ]; then
48+
echo "Error: MAP_STORAGE_API_KEY is not set in GitHub Secrets."
49+
exit 1
50+
fi
51+
echo "MAP_STORAGE_API_KEY=${{ secrets.MAP_STORAGE_API_KEY }}" >> $GITHUB_ENV
52+
53+
# MAP_STORAGE_URL can fall back to .env if not in GitHub Secrets
54+
if [ -n "${{ secrets.MAP_STORAGE_URL }}" ]; then
55+
echo "MAP_STORAGE_URL=${{ secrets.MAP_STORAGE_URL }}" >> $GITHUB_ENV
56+
else
57+
MAP_STORAGE_URL=$(grep '^[^#]*MAP_STORAGE_URL' .env | cut -d '=' -f2)
58+
if [ -z "$MAP_STORAGE_URL" ]; then
59+
echo "Error: MAP_STORAGE_URL is not set in GitHub Secrets or .env."
60+
exit 1
61+
fi
62+
echo "MAP_STORAGE_URL=$MAP_STORAGE_URL" >> $GITHUB_ENV
63+
fi
64+
65+
# UPLOAD_DIRECTORY can fall back to .env if not in GitHub Secrets, and to an arbitrary value if not in .env
66+
if [ -n "${{ secrets.UPLOAD_DIRECTORY }}" ]; then
67+
echo "UPLOAD_DIRECTORY=${{ secrets.UPLOAD_DIRECTORY }}" >> $GITHUB_ENV
68+
else
69+
UPLOAD_DIRECTORY=$(grep '^[^#]*UPLOAD_DIRECTORY' .env | cut -d '=' -f2)
70+
if [ -n "$UPLOAD_DIRECTORY" ]; then
71+
echo "UPLOAD_DIRECTORY=$UPLOAD_DIRECTORY" >> $GITHUB_ENV
72+
else
73+
USERNAME=${{ github.repository_owner }}
74+
REPO=${{ github.event.repository.name }}
75+
UPLOAD_DIRECTORY="${USERNAME}-${REPO}"
76+
echo "UPLOAD_DIRECTORY=$UPLOAD_DIRECTORY" >> $GITHUB_ENV
77+
echo "Warning: UPLOAD_DIRECTORY was not found; set to $UPLOAD_DIRECTORY."
78+
fi
79+
fi
80+
81+
- name: Deploy using WA Map Storage
82+
if: ${{ env.UPLOAD_MODE == 'MAP_STORAGE' }}
83+
run: npm run upload-only
84+
85+
- name: Deploy using Github Pages
86+
if: ${{ env.UPLOAD_MODE == 'GH_PAGES' }}
3087
uses: JamesIves/github-pages-deploy-action@releases/v3
31-
if: github.ref == 'refs/heads/master'
3288
with:
3389
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
BRANCH: gh-pages # The branch the action should deploy to.
35-
FOLDER: dist/ # The folder the action should deploy.
90+
BRANCH: gh-pages
91+
FOLDER: dist/
3692
BASE_BRANCH: master
3793

38-
- name: Bash2
39-
run: |
40-
ls -al

README.md

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,94 @@
1-
# WorkAdventure Map Starter Kit
1+
# 🗺️ WorkAdventure Map Starter Kit
22

3-
![map](./map.png)
3+
<a href="https://discord.gg/G6Xh9ZM9aR" target="blank"><img src="https://img.shields.io/discord/821338762134290432.svg?style=flat&label=Join%20Community&color=7289DA" alt="Join Community Badge"/></a>
4+
<a href="https://x.com/workadventure_" target="blank"><img src="https://img.shields.io/twitter/follow/workadventure_.svg?style=social" /></a>
5+
![visitors](https://vbr.nathanchung.dev/badge?page_id=workadventure.map-starter-kit&color=00cf00)
46

5-
This is a starter kit to help you build your own map for [WorkAdventure](https://workadventu.re).
7+
![office map thumbnail](./office.png)
68

7-
To understand how to use this starter kit, follow the tutorial at [https://workadventu.re/map-building](https://workadventu.re/map-building).
9+
🗺️ This is a starter kit to help you build your own map for [WorkAdventure](https://workadventu.re).
810

9-
## Structure
10-
* *public*: Static files like PDFs or audio files
11-
* *src*: Scripts files
12-
* *tilesets*: All tilesets
13-
* *map.tmj*: Map file
14-
* *map.png*: The map thumbnail displayed on the in-game map information
11+
📚 To understand how to use this starter kit, follow [our tutorial](https://docs.workadventu.re/map-building/tiled-editor/).
1512

16-
If you want to use more than one map file, just add the new map file on root or in a folder.
13+
👨🏻‍🔧 If you have any questions, feel free to ask in the [WorkAdventure office](https://play.staging.workadventu.re/@/tcm/workadventure/wa-village).
1714

18-
we recommend using 500x500 images for the map thumbnails.
15+
## 🚀 Upload your map
1916

20-
If you are going to create custom websites to embed in the map, please reference the HTML files in the `input` option in *vite.config.js*.
17+
In the `.env` file, you can set your upload strategy to `GH_PAGES` (default) or `MAP_STORAGE`. Simply comment out the option you don't want to use.
2118

22-
## Requirements
19+
Uploading a map using [GitHub Pages](https://docs.github.com/pages) will host your project on GitHub servers, and it's the most straightforward way to add new maps to your world.
2320

24-
Node.js version >=16
21+
Uploading a map using the [WA map storage](https://docs.workadventu.re/map-building/tiled-editor/publish/wa-hosted) will host your project on WA servers. It's a bit more difficult to set up, but it comes with great advantages, like being able to have private repositories.
2522

26-
## Installation
23+
## 🗂️ Structure
2724

28-
With npm installed (comes with [node](https://nodejs.org/en/)), run the following commands into a terminal in the root directory of this project:
25+
We recommend following this file structure:
2926

30-
```shell
27+
- *`public/`*: Static files like PDFs or audio files
28+
- *`src/`*: Script files or design source files
29+
- *`tilesets/`*: All PNG tilesets
30+
31+
> [!TIP]
32+
> - If you want to use more than one map file, just add the new map file in the root folder (we recommend creating a copy of *office.tmj* and editing it to avoid any mistakes).
33+
> - We recommend using **512x512** images for the map thumbnails.
34+
> - If you are going to create custom websites to embed in the map, please reference the HTML files in the `input` option in *vite.config.js*.
35+
36+
## 📜 Requirements
37+
38+
- Node.js version >= 18
39+
40+
## Installation and testing
41+
42+
## 🛠️ Installation and Testing
43+
44+
With npm installed (which comes with [Node.js](https://nodejs.org/en/)), run the following command in the root directory of the project:
45+
46+
```bash
3147
npm install
48+
```
49+
50+
Then, you can test your map by running:
51+
52+
```bash
3253
npm run dev
3354
```
3455

35-
## Test production map
56+
You can also test the optimized map as it will be in production by running:
3657

37-
You can test the optimized map as it will be in production:
38-
```sh
58+
```bash
3959
npm run build
4060
npm run prod
4161
```
4262

43-
## Licenses
63+
You can manually [upload your map to the WA Map Storage]([WA Map Storage](https://github.com/workadventure/upload-maps)) by running:
64+
65+
```bash
66+
npm run upload
67+
```
68+
69+
The three important variables that control the upload feature are:
70+
71+
1. `MAP_STORAGE_URL` *(local: created in .env by the upload command / CI: to be added as a Github secret optionally)*
72+
2. `MAP_STORAGE_API_KEY` *(local: created in .env.secret by the upload command / CI: to be added as a Github secret)*
73+
3. `UPLOAD_DIRECTORY` *(local: created in .env by the upload command / CI: to be added as a Github secret optionally)*
74+
75+
Read [the documentation](https://docs.workadventu.re/map-building/tiled-editor/publish/wa-hosted) to learn more about the upload feature.
76+
77+
## 📜 Licenses
4478

4579
This project contains multiple licenses as follows:
4680

4781
* [Code license](./LICENSE.code) *(all files except those for other licenses)*
48-
* [Map license](./LICENSE.map) *(`map.tmj` and the map visual as well)*
49-
* [Assets license](./LICENSE.assets) *(the files inside the `src/assets/` folder)*
82+
* [Map license](./LICENSE.map) *(`office.tmj` and the map visual as well)*
83+
* [Assets license](./LICENSE.assets) *(the files inside the `tilesets/` folder)*
84+
85+
> [!IMPORTANT]
86+
> If you add third party assets in your map, do not forget to:
87+
> 1. Credit the author and license of a tileset with the "tilesetCopyright" property by etiding the tileset in Tiled.
88+
> 2. Add the tileset license text in *LICENSE.assets*.
89+
> 3. Credit the author and license of a map with the "mapCopyright" property in the custom properties of the map.
90+
> 4. Add the map license text in *LICENSE.map*.
5091
51-
### About third party assets
92+
## ❓ Need Help
5293

53-
If you add third party assets in your map, do not forget to:
54-
1. Credit the author and license with the "tilesetCopyright" property present in the properties of each tilesets in the `map.tmj` file
55-
2. Add the license text in LICENSE.assets
94+
If you have any questions or need further assistance, don't hesitate to ask either by [email](mailto:hello@workadventu.re) or [Discord](https://discord.gg/G6Xh9ZM9aR)!

0 commit comments

Comments
 (0)