Skip to content

Commit 35301d4

Browse files
authored
Merge pull request #48 from candybox2/ci-github-pages
ci(workflows): build and deploy via GitHub Actions
2 parents 1a799a2 + d2bc669 commit 35301d4

6 files changed

Lines changed: 73 additions & 50787 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
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: Generate TypeScript sources from ascii art and translations
26+
working-directory: pythonScripts
27+
env:
28+
PYTHONUTF8: "1"
29+
run: |
30+
mkdir -p ../code/gen
31+
python3 genAscii.py
32+
python3 genText.py
33+
34+
- name: Compile TypeScript
35+
run: |
36+
npx --yes --package typescript@1.7.5 -- tsc ./libs/*.ts ./code/main/*.ts ./code/gen/*.ts ./code/arena/*/*.ts --out ./candybox2_compiled.js --target ES5
37+
38+
- name: Minify
39+
run: |
40+
npx --yes terser ./candybox2_compiled.js -o ./candybox2_minified.js --compress --mangle
41+
42+
- name: Assemble site
43+
run: |
44+
mkdir _site
45+
rsync -a --exclude '.git' --exclude '.github' --exclude '_site' --exclude 'candybox2_compiled.js' --exclude 'candybox2_minified.js' ./ _site/
46+
cat candybox2_sourceCodeLicense.txt candybox2_minified.js > _site/candybox2.js
47+
cat candybox2_sourceCodeLicense.txt candybox2_compiled.js > _site/candybox2_uncompressed.js
48+
49+
- name: Configure GitHub Pages
50+
uses: actions/configure-pages@v5
51+
with:
52+
enablement: true
53+
54+
- name: Upload Pages artifact
55+
uses: actions/upload-pages-artifact@v3
56+
with:
57+
path: _site
58+
59+
deploy:
60+
needs: build
61+
runs-on: ubuntu-latest
62+
environment:
63+
name: github-pages
64+
url: ${{ steps.deployment.outputs.page_url }}
65+
steps:
66+
- name: Deploy to GitHub Pages
67+
id: deployment
68+
uses: actions/deploy-pages@v4

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
**/*.pyc
22
**/*.zip
3+
4+
# Build artifacts (built and deployed by GitHub Actions, see .github/workflows/deploy.yml)
5+
/candybox2.js
6+
/candybox2_uncompressed.js
7+
/code/gen/

0 commit comments

Comments
 (0)