1- name : public_html update
1+ name : Deploy GitHub Pages
22on :
33 push :
44 branches :
5- - main
6- paths :
7- - public_html/**
8- workflow_dispatch :
9- inputs :
10- manual :
11- description : Manually updates the public_html!
12-
5+ - main
136jobs :
147 build :
15- name : public_html Updater
8+ name : Build
169 runs-on : ubuntu-latest
1710 steps :
18- - name : checkout repository
19- uses : actions/checkout@v4
20-
21- - name : Copy files
22- run : |
23- mkdir -p /home/runner/work/obhqWebsite/temp/public_html/
24- cp -a -r -f /home/runner/work/obhqWebsite/obhqWebsite/public_html/* /home/runner/work/obhqWebsite/temp/public_html/
25-
26- - name : Commit and push changes to gh-pages
27- run : |
28- # Switch to gh-pages
29- git config --global user.name "GitHub Actions"
30- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
31- git fetch origin gh-pages
32- git switch gh-pages --force
33-
34- # put the new files into the folder
35- rm -r -f /home/runner/work/obhqWebsite/obhqWebsite/*
36- mv -f /home/runner/work/obhqWebsite/temp/public_html/* /home/runner/work/obhqWebsite/obhqWebsite/
37- touch /home/runner/work/obhqWebsite/obhqWebsite/.nojekyll
38- git add /home/runner/work/obhqWebsite/obhqWebsite/ -f
39-
40- # restore files that dont need updating
41- git restore --staged --worktree wiki/
42- git restore --staged --worktree download/artifacts/
43- git restore --staged --worktree compatibility/_images/games/
44- git restore --staged --worktree compatibility/_images/hb/
45- git restore --staged --worktree compatibility/database.json
46- git restore --staged --worktree stats.json
47-
48- files_to_commit=$(git status --porcelain | grep -E 'M|A|D' | wc -l)
49- if [ $files_to_commit -gt 0 ]; then
50- echo "Committing changes!"
51- git fetch origin gh-pages
52- git commit -m "Automatic public_html update"
53- git push origin gh-pages
54- else
55- echo "No changes to commit."
56- fi
11+ - name : Checkout repository
12+ uses : actions/checkout@v4
13+ - name : Upload artifacts
14+ uses : actions/upload-pages-artifact@v3.0.1
15+ with :
16+ path : src
17+ deploy :
18+ name : Deploy
19+ runs-on : ubuntu-latest
20+ needs : build
21+ environment :
22+ name : github-pages
23+ url : ${{ steps.deployment.outputs.page_url }}
24+ permissions :
25+ pages : write
26+ id-token : write
27+ steps :
28+ - name : Deploy to GitHub Pages
29+ uses : actions/deploy-pages@v4
30+ id : deployment
0 commit comments