Skip to content

Commit 88eeb6f

Browse files
committed
Add initial deployment configuration and redirect handling
- Created 404.html for handling page not found redirects. - Added Dockerfile for Nginx setup. - Introduced docker-compose.yml for container orchestration. - Updated index.html to redirect from GitHub Pages to the new site. - Configured nginx.conf for serving static files. - Established GitHub Actions workflows for deploying to GCP and GitHub Pages.
1 parent af7403a commit 88eeb6f

7 files changed

Lines changed: 113 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Deploy to GCP
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Pull and optionally restart
13+
uses: appleboy/ssh-action@v1.2.0
14+
with:
15+
host: ${{ secrets.SERVER_HOST }}
16+
username: ${{ secrets.SERVER_USER }}
17+
key: ${{ secrets.SERVER_SSH_KEY }}
18+
script: |
19+
cd /opt/boost
20+
git fetch origin main
21+
CHANGED=$(git diff HEAD origin/main --name-only)
22+
git pull origin main
23+
if echo "$CHANGED" | grep -qE "^(Dockerfile|nginx\.conf|docker-compose\.yml)$"; then
24+
docker compose up -d --build
25+
fi

.github/workflows/pages.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy GitHub Pages (redirect only)
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'index.html'
8+
- '404.html'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: true
19+
20+
jobs:
21+
deploy:
22+
environment:
23+
name: github-pages
24+
url: ${{ steps.deployment.outputs.page_url }}
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Prepare redirect-only artifact
31+
run: |
32+
mkdir _pages
33+
cp index.html _pages/
34+
cp 404.html _pages/
35+
36+
- name: Setup Pages
37+
uses: actions/configure-pages@v5
38+
39+
- name: Upload Pages artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: _pages
43+
44+
- name: Deploy to GitHub Pages
45+
id: deployment
46+
uses: actions/deploy-pages@v4

404.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Redirecting...</title>
7+
<script>
8+
window.location.replace(
9+
'https://dev.cppdigest.org/boost' + window.location.pathname
10+
);
11+
</script>
12+
</head>
13+
<body>
14+
<p>Redirecting to <a href="https://dev.cppdigest.org/boost/">dev.cppdigest.org/boost/</a>&hellip;</p>
15+
</body>
16+
</html>

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM nginx:alpine
2+
COPY nginx.conf /etc/nginx/conf.d/default.conf

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
boost-site:
3+
build: .
4+
container_name: boost-site
5+
ports:
6+
- "9102:80"
7+
volumes:
8+
- /opt/boost:/usr/share/nginx/html:ro
9+
restart: unless-stopped

index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Boost Library Usage Analysis</title>
7+
<script>
8+
if (window.location.hostname === 'cppdigest.github.io') {
9+
window.location.replace('https://dev.cppdigest.org/boost/');
10+
}
11+
</script>
712
<style>
813
* {
914
margin: 0;

nginx.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
root /usr/share/nginx/html;
5+
index index.html;
6+
7+
location / {
8+
try_files $uri $uri/ =404;
9+
}
10+
}

0 commit comments

Comments
 (0)