Skip to content

Commit ef12cd8

Browse files
added action
0 parents  commit ef12cd8

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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"

0 commit comments

Comments
 (0)