Skip to content

Commit accc5dd

Browse files
Testing github pages workflow
1 parent e00b66e commit accc5dd

File tree

6 files changed

+118
-1
lines changed

6 files changed

+118
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
# Allow only one concurrent deployment
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "20"
29+
cache: "yarn"
30+
31+
- name: Install dependencies
32+
run: yarn install --frozen-lockfile
33+
34+
- name: Build
35+
run: yarn build
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v4
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: "./public"
44+
45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
runs-on: ubuntu-latest
50+
needs: build
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
1-
# arduino-tilemap-editor
1+
# Arduino Tilemap Editor
2+
23
Create, edit, and export tilemaps directly to C++ header files for Arduino-powered devices.
4+
5+
## Live Demo
6+
7+
You can try the application online at [https://halftheopposite.github.io/arduino-tilemap-editor](https://halftheopposite.github.io/arduino-tilemap-editor)
8+
9+
## Development
10+
11+
### Prerequisites
12+
13+
- Node.js (v14 or higher)
14+
- Yarn
15+
16+
### Installation
17+
18+
```bash
19+
# Clone the repository
20+
git clone https://github.com/halftheopposite/arduino-tilemap-editor.git
21+
cd arduino-tilemap-editor
22+
23+
# Install dependencies
24+
yarn install
25+
26+
# Start the development server
27+
yarn start
28+
```
29+
30+
The application will be available at http://localhost:3000
31+
32+
### Building
33+
34+
```bash
35+
yarn build
36+
```
37+
38+
This will create a production build in the `public` directory.
39+
40+
## Deployment
41+
42+
The application is automatically deployed to GitHub Pages when changes are pushed to the main branch using GitHub Actions.
43+
44+
## License
45+
46+
MIT

esbuild.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const isServe = args.includes("--serve");
77

88
const PORT = 3000;
99

10+
// Check if we're building for GitHub Pages
11+
const isGitHubPages = process.env.GITHUB_ACTIONS === "true";
12+
1013
const buildOptions = {
1114
entryPoints: ["src/index.tsx"],
1215
bundle: true,
@@ -22,6 +25,8 @@ const buildOptions = {
2225
".ts": "tsx",
2326
},
2427
jsx: "automatic",
28+
// Set the public path for GitHub Pages if needed
29+
publicPath: isGitHubPages ? "/arduino-tilemap-editor" : "/",
2530
};
2631

2732
// Function to start the development server

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "arduino-tilemap-editor",
33
"version": "0.1.0",
44
"description": "Create, edit, and export tilemaps directly to C++ header files for Arduino.",
5+
"homepage": "https://halftheopposite.github.io/arduino-tilemap-editor",
56
"scripts": {
67
"start": "node esbuild.config.js --serve",
78
"build": "node esbuild.config.js"

public/.nojekyll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

public/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
name="description"
99
content="Create, edit, and export tilemaps directly to C++ header files for Arduino."
1010
/>
11+
<!-- Base URL for GitHub Pages deployment -->
12+
<script>
13+
// Dynamically set the base URL based on the environment
14+
(function () {
15+
const isGitHubPages = window.location.hostname.includes("github.io");
16+
if (isGitHubPages) {
17+
const baseElement = document.createElement("base");
18+
baseElement.href = "/arduino-tilemap-editor/";
19+
document.head.appendChild(baseElement);
20+
}
21+
})();
22+
</script>
1123
<link rel="stylesheet" href="styles.css" />
1224
</head>
1325
<body>

0 commit comments

Comments
 (0)