-
Notifications
You must be signed in to change notification settings - Fork 36
80 lines (70 loc) · 2.51 KB
/
Copy pathdeploy.yml
File metadata and controls
80 lines (70 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Auto Deploy Report
on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: "🔄 Checkout code"
uses: actions/checkout@v4
- name: "🐹 Set up Go"
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: "🔧 Setup environment variables from secrets"
env:
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
run: |
echo "Setting up environment variables from GitHub secrets..."
echo "$SECRETS_CONTEXT" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV
echo "Environment variables configured from secrets"
- name: "🏗️ Build and run PongHub"
run: |
mkdir -p bin data
git clone --branch gh-pages https://github.com/${{ github.repository }}.git || true
if [ -f ponghub/ponghub_log.json ]; then
cp ponghub/ponghub_log.json data/ponghub_log.json
else
echo "New installation, no previous data found."
fi
make run || true
- name: "📦 Prepare publish directory"
run: |
mkdir -p publish/static
cp -r data/* publish/
cp -r static/* publish/static/
if [ -f CNAME ]; then
cp CNAME publish/
else
echo "No CNAME file found."
fi
touch publish/.nojekyll
- name: "🚀 Deploy to GitHub Pages"
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: publish
single-commit: true
git-config-name: github-pages-deploy-action
git-config-email: noreply@github.com
- name: "⚠️ Handle Service Notifications"
run: |
if [ -f data/default_enabled.txt ] && [ -s data/default_enabled.txt ] && [ "$(cat data/default_enabled.txt)" = "true" ]; then
if [ -f data/notify.txt ] && [ -s data/notify.txt ]; then
echo "Service issues detected:"
cat data/notify.txt
echo "Default notification enabled, failing workflow."
exit 1
fi
else
if [ -f data/notify.txt ] && [ -s data/notify.txt ]; then
echo "Service issues detected:"
cat data/notify.txt
echo "Service issues have been reported through the configured notification channels."
else
echo "No service issues detected."
fi
fi