-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (48 loc) · 1.58 KB
/
Copy pathdeploy_pages.yml
File metadata and controls
59 lines (48 loc) · 1.58 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
name: Deploy GitHub Pages
on:
push:
branches:
- master
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout master branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy to docs branch
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Create a temporary directory for the site content
mkdir temp_site
cp -r docs/* temp_site/
# Fetch all branches
git fetch origin
# Switch to (or create) the docs branch
if git show-ref --verify --quiet refs/remotes/origin/docs; then
# Use -B to explicitly set up the branch and track the remote, bypassing ambiguity
git checkout -B docs origin/docs
else
git checkout --orphan docs
git rm -rf .
fi
# Clear current branch content
git rm -rf .
# Move site content to root
mv temp_site/* .
rmdir temp_site
# Creating CNAME file
echo "offchat.creatorjohn.com" >> CNAME
# Commit and push only if there are changes
git add .
if git diff-index --quiet HEAD; then
echo "No changes to deploy."
else
git commit -m "Automated Pages Deployment: $(date)"
git push -f origin docs
fi