Skip to content

Commit a4e4193

Browse files
authored
Merge pull request #2 from feat/kyau-bb48-workflow
feat/kyau-bb48-workflow
2 parents 595091b + bb2cb2a commit a4e4193

File tree

14 files changed

+267
-83
lines changed

14 files changed

+267
-83
lines changed

.github/media/git-flow.svg

+1
Loading

.github/workflows/deploy.yml

+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# $KYAULabs: deploy.yml,v 1.1.0 2024/07/22 01:12:20 -0700 kyau Exp $
2+
3+
name: "🌌 Hexforged CI"
4+
5+
on:
6+
push:
7+
branches: ["main", "develop"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
deploy:
12+
name: Deploy 🚀
13+
runs-on: ubuntu-latest
14+
steps:
15+
# https://github.com/marketplace/actions/checkout
16+
- name: Checkout 💾
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
submodules: true
21+
22+
# create CSS directory
23+
- name: Create CSS Directory 🚧
24+
run: mkdir -vp hexforged_com/cdn/css
25+
26+
# https://github.com/marketplace/actions/sass-build
27+
- name: Compile Sass 👷
28+
uses: gha-utilities/[email protected]
29+
with:
30+
source: hexforged_com/cdn/sass/hexforged.sass
31+
destination: hexforged_com/cdn/css/hexforged.css
32+
33+
# https://github.com/marketplace/actions/release-downloader
34+
- name: Download jQuery Release 💾
35+
uses: robinraju/[email protected]
36+
with:
37+
repository: "tdewolff/minify"
38+
latest: true
39+
fileName: "minify_linux_amd64.tar.gz"
40+
out-file-path: "/tmp/downloads"
41+
extract: true
42+
43+
- name: Minify CSS/JS 📦️
44+
run: |
45+
chmod a+x /tmp/downloads/minify
46+
for file in hexforged_com/cdn/css/*.css; do
47+
if [ -f "$file" ]; then
48+
/tmp/downloads/minify $file -o ${file%.css}.min.css
49+
rm $file
50+
fi
51+
done
52+
for file in hexforged_com/cdn/javascript/*.js; do
53+
if [ -f "$file" ]; then
54+
/tmp/downloads/minify $file -o ${file%.js}.min.js
55+
rm $file
56+
fi
57+
done
58+
59+
# https://github.com/marketplace/actions/release-downloader
60+
- name: Download jQuery Release 💾
61+
uses: robinraju/[email protected]
62+
with:
63+
repository: "jquery/jquery"
64+
latest: true
65+
tarBall: true
66+
zipBall: false
67+
out-file-path: "/tmp/downloads"
68+
extract: true
69+
70+
# https://github.com/marketplace/actions/release-downloader
71+
- name: Download Font Awesome Release 💾
72+
uses: robinraju/[email protected]
73+
with:
74+
repository: "FortAwesome/Font-Awesome"
75+
latest: true
76+
fileName: "fontawesome-free-*-web.zip"
77+
out-file-path: "/tmp/downloads"
78+
extract: true
79+
80+
- name: Copy jQuery & FontAwesome 🔗
81+
run: |
82+
cp /tmp/downloads/fontawesome-free-*-web/css/all.min.css hexforged_com/cdn/css/
83+
cp /tmp/downloads/fontawesome-free-*-web/css/fontawesome.min.css hexforged_com/cdn/css/
84+
sed -i 's|\.\./webfonts/|\.\./fonts/|g' hexforged_com/cdn/css/all.min.css
85+
cp /tmp/downloads/jquery-jquery-*/dist/jquery.min.js hexforged_com/cdn/javascript/
86+
cp /tmp/downloads/jquery-jquery-*/dist/jquery.min.map hexforged_com/cdn/javascript/
87+
88+
# subresource integrity
89+
- name: Subresource Integrity 🔒️
90+
id: subresource
91+
run: |
92+
for file in hexforged_com/cdn/css/*.min.css; do
93+
if [ -f "$file" ]; then
94+
shasum -b -a 512 ${file} | awk '{ print $1 }' | xxd -r -p | base64 | tr -d '\n' > ${file}.sha512
95+
fi
96+
done
97+
for file in hexforged_com/cdn/javascript/*.min.js; do
98+
if [ -f "$file" ]; then
99+
shasum -b -a 512 ${file} | awk '{ print $1 }' | xxd -r -p | base64 | tr -d '\n' > ${file}.sha512
100+
fi
101+
done
102+
103+
# create dotenv
104+
- name: Create DotENV 🔐
105+
id: dotenv
106+
run: |
107+
echo -e "<?php\n" > .env
108+
echo -e "define(\"GOOGLE_PUBLIC\", \"${{ secrets.GOOGLE_PUBLIC }}\");" >> .env
109+
echo -e "define(\"GOOGLE_SECRET\", \"${{ secrets.GOOGLE_SECRET }}\");" >> .env
110+
echo -e "define(\"SQL_USER\", \"${{ secrets.SQL_USER }}\");" >> .env
111+
echo -e "define(\"SQL_PASSWD\", \"${{ secrets.SQL_PASSWD }}\");" >> .env
112+
- name: Detect Production Environment 🎬
113+
if: github.ref == 'refs/heads/main'
114+
run: |
115+
echo -e "define(\"CDN_HOST\", \"cdn.hexforged.com\");" >> .env
116+
echo -e "define(\"ENVIRONMENT\", \"production\");" >> .env
117+
- name: Detect Development Environment ⚗️
118+
if: github.ref == 'refs/heads/develop'
119+
run: |
120+
echo -e "define(\"CDN_HOST\", \"cdn.dev.hexforged.com\");" >> .env
121+
echo -e "define(\"ENVIRONMENT\", \"development\");" >> .env
122+
123+
# https://github.com/marketplace/actions/rsync-deployments-action
124+
- name: Rsync to Production 🚀
125+
if: github.ref == 'refs/heads/main'
126+
uses: burnett01/[email protected]
127+
with:
128+
switches: -avzr --exclude=".git" --exclude="aurora/.git"
129+
remote_path: ${{ secrets.TARGET }}
130+
remote_host: ${{ secrets.SSH_HOST }}
131+
remote_user: ${{ secrets.SSH_USER }}
132+
remote_key: ${{ secrets.SSH_KEY }}
133+
remote_key_pass: ${{ secrets.SSH_PASSWD }}
134+
remote_port: ${{ secrets.SSH_PORT }}
135+
136+
# https://github.com/marketplace/actions/rsync-deployments-action
137+
- name: Rsync to Development 🚀
138+
if: github.ref == 'refs/heads/develop'
139+
uses: burnett01/[email protected]
140+
with:
141+
switches: -avzr --exclude=".git" --exclude="aurora/.git"
142+
remote_path: ${{ secrets.TARGET }}
143+
remote_host: ${{ secrets.SSH_HOST_DEV }}
144+
remote_user: ${{ secrets.SSH_USER }}
145+
remote_key: ${{ secrets.SSH_KEY }}
146+
remote_key_pass: ${{ secrets.SSH_PASSWD }}
147+
remote_port: ${{ secrets.SSH_PORT }}
148+
149+
# https://github.com/marketplace/actions/ssh-remote-commands
150+
- name: Confirm Permissions 🔑
151+
uses: appleboy/[email protected]
152+
with:
153+
host: ${{ secrets.SSH_HOST_DEV }}
154+
username: ${{ secrets.SSH_USER }}
155+
key: ${{ secrets.SSH_KEY }}
156+
passphrase: ${{ secrets.SSH_PASSWD }}
157+
port: ${{ secrets.SSH_PORT }}
158+
script: |
159+
find ${{ secrets.TARGET }} -type d -exec chmod 2770 {} \;
160+
find ${{ secrets.TARGET }} -type f -exec chmod 660 {} \;
161+
162+
# https://github.com/marketplace/actions/ssh-remote-commands
163+
- name: Reset the Development Database 🗃️
164+
if: github.ref == 'refs/heads/develop'
165+
uses: appleboy/[email protected]
166+
with:
167+
host: ${{ secrets.SSH_HOST_DEV }}
168+
username: ${{ secrets.SSH_USER }}
169+
key: ${{ secrets.SSH_KEY }}
170+
passphrase: ${{ secrets.SSH_PASSWD }}
171+
port: ${{ secrets.SSH_PORT }}
172+
script: |
173+
mariadb -u ${{ secrets.SQL_USER }} -e 'DROP DATABASE hexforged'
174+
mariadb -u ${{ secrets.SQL_USER }} < ${{ secrets.TARGET }}/hexforged_com/backend/hexforged.sql

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*.jpeg
1313
*.gif
1414
*.svg
15+
!.github/media/git-flow.svg
1516
!hexforged_com/cdn/images/[email protected]
1617

1718
# Checksum files

.gitleaksignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dd41b25699ad82adcca5bceecae0302c3362f876:hexforged_com/www/hexforged.php:generic-api-key:122

error/403.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
*
5-
* $KYAULabs: 403.php,v 1.0.1 2024/07/17 13:47:05 -0700 kyau Exp $
5+
* $KYAULabs: 403.php,v 1.0.2 2024/07/22 22:29:11 -0700 kyau Exp $
66
* ▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
77
* █ ▄▄ ▄ ▄▄▄▄ ▄▄ ▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄ ▄▄▄ ▀
88
* █ ██ █ ██ ▀ ██ █ ██ ▀ ██ █ ██ █ ██ ██ ▀ ██ █ █
@@ -29,15 +29,16 @@
2929
*/
3030

3131
$rus = getrusage();
32-
require_once("../aurora/aurora.inc.php");
32+
require_once(__DIR__ . '/../.env');
33+
require_once(__DIR__ . '/../aurora/aurora.inc.php');
3334

34-
$hexforged = new KYAULabs\Aurora("index.html", "/nginx/https/hexforged_com/www", "hexforged.com", true, true);
35+
$hexforged = new KYAULabs\Aurora("index.html", "/hexforged_com/cdn", true, true);
3536
$hexforged->title = 'Hexforged: 403 Access Restricted!';
3637
$hexforged->description = "A multiplayer RPG prototype developed by KYAU Labs.";
37-
$hexforged->api = ["cdn.hexforged.com"];
38+
$hexforged->dns = [CDN_HOST];
3839
$hexforged->preload = [
3940
'/css/hexforged.min.css' => 'style',
40-
'/javascript/jquery-3.7.1.min.js' => 'script',
41+
'/javascript/jquery.min.js' => 'script',
4142
'/fonts/Agave-Regular.ttf' => 'font',
4243
'/fonts/Agave-Bold.ttf' => 'font',
4344
'/fonts/SavaPro-Light.otf' => 'font',
@@ -48,13 +49,13 @@
4849
'/fonts/SavaPro-Black.otf' => 'font',
4950
];
5051
$hexforged->css = [
51-
'../hexforged_com/cdn/css/fontawesome.min.css' => '//cdn.hexforged.com/css/fontawesome.min.css',
52-
'../hexforged_com/cdn/css/fa-all.min.css' => '//cdn.hexforged.com/css/fa-all.min.css',
53-
'../hexforged_com/cdn/css/hexforged.min.css' => '//cdn.hexforged.com/css/hexforged.min.css',
52+
'../hexforged_com/cdn/css/fontawesome.min.css' => '//' . CDN_HOST . '/css/fontawesome.min.css',
53+
'../hexforged_com/cdn/css/all.min.css' => '//' . CDN_HOST . '/css/all.min.css',
54+
'../hexforged_com/cdn/css/hexforged.min.css' => '//' . CDN_HOST . '/css/hexforged.min.css',
5455
];
5556
$hexforged->js = [
56-
'../hexforged_com/cdn/javascript/jquery-3.7.1.min.js' => '//cdn.hexforged.com/javascript/jquery-3.7.1.min.js',
57-
'../hexforged_com/cdn/javascript/hexforged.min.js' => '//cdn.hexforged.com/javascript/hexforged.min.js',
57+
'../hexforged_com/cdn/javascript/jquery.min.js' => '//' . CDN_HOST . '/javascript/jquery.min.js',
58+
'../hexforged_com/cdn/javascript/hexforged.min.js' => '//' . CDN_HOST . '/javascript/hexforged.min.js',
5859
];
5960
$hexforged->htmlHeader();
6061
// <content>

error/404.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
*
5-
* $KYAULabs: 404.php,v 1.0.1 2024/07/17 00:55:39 -0700 kyau Exp $
5+
* $KYAULabs: 404.php,v 1.0.2 2024/07/22 22:29:19 -0700 kyau Exp $
66
* ▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
77
* █ ▄▄ ▄ ▄▄▄▄ ▄▄ ▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄ ▄▄▄ ▀
88
* █ ██ █ ██ ▀ ██ █ ██ ▀ ██ █ ██ █ ██ ██ ▀ ██ █ █
@@ -29,15 +29,16 @@
2929
*/
3030

3131
$rus = getrusage();
32+
require_once(__DIR__ . '/../.env');
3233
require_once(__DIR__ . '/../aurora/aurora.inc.php');
3334

34-
$hexforged = new KYAULabs\Aurora('index.html', '/nginx/https/hexforged_com/www', 'hexforged.com', true, true);
35+
$hexforged = new KYAULabs\Aurora('index.html', '/hexforged_com/cdn', true, true);
3536
$hexforged->title = 'Hexforged: 404 Not Found!';
3637
$hexforged->description = 'A multiplayer RPG prototype developed by KYAU Labs.';
37-
$hexforged->api = ['cdn.hexforged.com'];
38+
$hexforged->dns = [CDN_HOST];
3839
$hexforged->preload = [
3940
'/css/hexforged.min.css' => 'style',
40-
'/javascript/jquery-3.7.1.min.js' => 'script',
41+
'/javascript/jquery.min.js' => 'script',
4142
'/fonts/Agave-Regular.ttf' => 'font',
4243
'/fonts/Agave-Bold.ttf' => 'font',
4344
'/fonts/SavaPro-Light.otf' => 'font',
@@ -48,13 +49,13 @@
4849
'/fonts/SavaPro-Black.otf' => 'font',
4950
];
5051
$hexforged->css = [
51-
'../hexforged_com/cdn/css/fontawesome.min.css' => '//cdn.hexforged.com/css/fontawesome.min.css',
52-
'../hexforged_com/cdn/css/fa-all.min.css' => '//cdn.hexforged.com/css/fa-all.min.css',
53-
'../hexforged_com/cdn/css/hexforged.min.css' => '//cdn.hexforged.com/css/hexforged.min.css',
52+
'../hexforged_com/cdn/css/fontawesome.min.css' => '//' . CDN_HOST . '/css/fontawesome.min.css',
53+
'../hexforged_com/cdn/css/all.min.css' => '//' . CDN_HOST . '/css/all.min.css',
54+
'../hexforged_com/cdn/css/hexforged.min.css' => '//' . CDN_HOST . '/css/hexforged.min.css',
5455
];
5556
$hexforged->js = [
56-
'../hexforged_com/cdn/javascript/jquery-3.7.1.min.js' => '//cdn.hexforged.com/javascript/jquery-3.7.1.min.js',
57-
'../hexforged_com/cdn/javascript/hexforged.min.js' => '//cdn.hexforged.com/javascript/hexforged.min.js',
57+
'../hexforged_com/cdn/javascript/jquery.min.js' => '//' . CDN_HOST . '/javascript/jquery.min.js',
58+
'../hexforged_com/cdn/javascript/hexforged.min.js' => '//' . CDN_HOST . '/javascript/hexforged.min.js',
5859
];
5960
$hexforged->htmlHeader();
6061
// <content>

error/50x.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
*
5-
* $KYAULabs: 50x.php,v 1.0.1 2024/07/17 00:53:59 -0700 kyau Exp $
5+
* $KYAULabs: 50x.php,v 1.0.2 2024/07/22 22:26:56 -0700 kyau Exp $
66
* ▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
77
* █ ▄▄ ▄ ▄▄▄▄ ▄▄ ▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄ ▄▄▄ ▀
88
* █ ██ █ ██ ▀ ██ █ ██ ▀ ██ █ ██ █ ██ ██ ▀ ██ █ █
@@ -31,15 +31,16 @@
3131

3232

3333
$rus = getrusage();
34+
require_once(__DIR__ . '/../.env');
3435
require_once(__DIR__ . '/../aurora/aurora.inc.php');
3536

36-
$hexforged = new KYAULabs\Aurora('index.html', '/nginx/https/hexforged_com/www', 'hexforged.com', true, true);
37+
$hexforged = new KYAULabs\Aurora('index.html', '/hexforged_com/cdn', true, true);
3738
$hexforged->title = 'Hexforged: 500 Internal Server Error!';
3839
$hexforged->description = 'A multiplayer RPG prototype developed by KYAU Labs.';
39-
$hexforged->api = ['cdn.hexforged.com'];
40+
$hexforged->dns = [CDN_HOST];
4041
$hexforged->preload = [
4142
'/css/hexforged.min.css' => 'style',
42-
'/javascript/jquery-3.7.1.min.js' => 'script',
43+
'/javascript/jquery.min.js' => 'script',
4344
'/fonts/Agave-Regular.ttf' => 'font',
4445
'/fonts/Agave-Bold.ttf' => 'font',
4546
'/fonts/SavaPro-Light.otf' => 'font',
@@ -50,13 +51,13 @@
5051
'/fonts/SavaPro-Black.otf' => 'font',
5152
];
5253
$hexforged->css = [
53-
'../hexforged_com/cdn/css/fontawesome.min.css' => '//cdn.hexforged.com/css/fontawesome.min.css',
54-
'../hexforged_com/cdn/css/fa-all.min.css' => '//cdn.hexforged.com/css/fa-all.min.css',
55-
'../hexforged_com/cdn/css/hexforged.min.css' => '//cdn.hexforged.com/css/hexforged.min.css',
54+
'../hexforged_com/cdn/css/fontawesome.min.css' => '//' . CDN_HOST . '/css/fontawesome.min.css',
55+
'../hexforged_com/cdn/css/all.min.css' => '//' . CDN_HOST . '/css/all.min.css',
56+
'../hexforged_com/cdn/css/hexforged.min.css' => '//' . CDN_HOST . '/css/hexforged.min.css',
5657
];
5758
$hexforged->js = [
58-
'../hexforged_com/cdn/javascript/jquery-3.7.1.min.js' => '//cdn.hexforged.com/javascript/jquery-3.7.1.min.js',
59-
'../hexforged_com/cdn/javascript/hexforged.min.js' => '//cdn.hexforged.com/javascript/hexforged.min.js',
59+
'../hexforged_com/cdn/javascript/jquery.min.js' => '//' . CDN_HOST . '/javascript/jquery.min.js',
60+
'../hexforged_com/cdn/javascript/hexforged.min.js' => '//' . CDN_HOST . '/javascript/hexforged.min.js',
6061
];
6162
$hexforged->htmlHeader();
6263
// <content>

0 commit comments

Comments
 (0)