File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy site via SSH Deploy Key
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ paths :
7+ - ' docs/**' # or '_site/**' if that’s where you render
8+ workflow_dispatch :
9+
10+ env :
11+ TARGET_SSH : git@github.com:DevStart-Hub/DevStart-Hub.github.io.git
12+ TARGET_BRANCH : main
13+ SOURCE_DIR : docs # or _site if you render there
14+
15+ jobs :
16+ deploy :
17+ runs-on : ubuntu-latest
18+ steps :
19+ - name : Checkout source
20+ uses : actions/checkout@v4
21+
22+ - name : Setup SSH
23+ run : |
24+ mkdir -p ~/.ssh
25+ echo "${{ secrets.PUBLISH_KEY }}" > ~/.ssh/id_ed25519
26+ chmod 600 ~/.ssh/id_ed25519
27+ ssh-keyscan github.com >> ~/.ssh/known_hosts
28+
29+ - name : Clone target repo
30+ run : git clone --depth 1 "$TARGET_SSH" publish
31+
32+ - name : Clean target (preserve CNAME/.nojekyll)
33+ run : |
34+ find publish -mindepth 1 -maxdepth 1 \
35+ ! -name ".git" ! -name "CNAME" ! -name ".nojekyll" -exec rm -rf {} +
36+
37+ - name : Copy site files
38+ run : rsync -av --delete --exclude ".git" "${SOURCE_DIR}/" publish/
39+
40+ - name : Commit & push
41+ working-directory : publish
42+ run : |
43+ git config user.email "github-actions[bot]@users.noreply.github.com"
44+ git config user.name "github-actions[bot]"
45+ git add -A
46+ git diff --quiet && echo "No changes." && exit 0
47+ git commit -m "Deploy from ${GITHUB_REPOSITORY}@${GITHUB_SHA::7}"
48+ git push origin "$TARGET_BRANCH"
You can’t perform that action at this time.
0 commit comments