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
|
name: Triển Khai Hexo
on:
push:
branches:
- main
env:
TZ: Asia/Ho_Chi_Minh
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Kiểm tra nguồn
uses: actions/checkout@v2
with:
ref: main
- name: Thiết lập Node.js
uses: actions/setup-node@v1
with:
node-version: "20"
- name: Cấu hình Hexo
env:
ACTION_DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$ACTION_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-keyscan gitee.com >> ~/.ssh/known_hosts
git config --global user.email "email_cua_ban@gmail.com"
git config --global user.name "Ten_cua_ban"
git config --global init.defaultBranch main
npm install hexo-cli -g
npm install
- name: Triển Khai
run: |
hexo clean
hexo generate
hexo deploy
- name: Sao chép lên máy chủ ECS
uses: cross-the-world/ssh-pipeline@master
env:
WELCOME: "ssh pipeline"
with:
host: ${{ secrets.USER_HOST }}
user: ${{ secrets.USER_NAME }}
pass: ${{ secrets.USER_PASS }}
connect_timeout: 10s
script: |
cd ${{ secrets.ECS_SITE }}
git clone --depth 1 -b gh-pages ${{ secrets.GH_USERNAME }}/${{ secrets.GH_REPO }}.git
rm -rf index
mv ${{ secrets.GH_REPO }} index
cd index
rm -rf .git
chown -R 1000:1000 .
|