Github Action 部署hexo并上传到ECS

使用Github Action自动生成网页并通过FTP协议上传到服务器
通过ftp传文件

以下是workflow文件

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
60
61
62
# This is a basic workflow to help you get started with Actions

name: deploy blog

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/setup-node@v2.1.5
with:
# Set always-auth in npmrc
always-auth: false # optional, default is false
# Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0
node-version: 14.16.0 # optional

- name: Install hexo
run: npm install hexo-cli -g && npm install

- name: hexo g
run: hexo clean && hexo g

- name: FTP Deploy
# You may pin to the exact commit or the version.
# uses: SamKirkland/FTP-Deploy-Action@2a4e9b1312ebeb73a1f72b9330c71831c1e4ce01
uses: SamKirkland/FTP-Deploy-Action@4.0.0
with:
# ftp server
server: ${{ secrets.server }}
# ftp username
username: ${{ secrets.username }}
# ftp password
password: ${{ secrets.password }}
# Server port to connect to (read your web hosts docs)
# protocol to deploy with - ftp, ftps, or ftps-legacy
# Folder to upload from, must end with trailing slash /
local-dir: ./public/
dangerous-clean-slate: false
server-dir: ./
# Path to upload to on the server. Must end with trailing slash /
- name: hexo deploy
run: |
echo "OK"

食用前请先去仓库设置创建SERVER USERNAME PASSWORD这三个secrets

更多信息请访问:https://github.com/marketplace/actions/ftp-deploy