-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 2.19 KB
/
sync-qiniu.yml
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
63
64
65
66
67
68
69
name: sync qiniu
on:
push:
paths-ignore:
- '.github/**'
- 'README.md'
jobs:
sync:
runs-on: ubuntu-latest
env:
# 文件过滤规则
BASE_FILE_PATTERNS: sh/**
# 七牛云空间名称
QINIU_BUCKET: assetss
steps:
- name: 检出代码到本地
uses: actions/checkout@v2
# qshell 使用文档 https://developer.qiniu.com/kodo/1302/qshell#5
- name: 下载七牛云命令行工具 qshell
run: |
# 下载 qshell 执行器
wget --no-check-certificate "https://github.com/qiniu/qshell/releases/download/v2.6.2/qshell-v2.6.2-linux-amd64.tar.gz"
# 解压
tar zxvf qshell-v2.6.2-linux-amd64.tar.gz
# 给执行权限
chmod +x qshell
# 设置账户
./qshell account -- ${{secrets.QINIU_AK}} ${{secrets.QINIU_SK}} iamc
- name: 获取改变文件
id: changedFiles
uses: jitterbit/get-changed-files@v1
- name: 过滤添加、修改、重命名的改变文件
id: filterUpload
if: ${{steps.changedFiles.outputs.added_modified || steps.changedFiles.outputs.renamed}}
uses: iamobj/action-minimatch@v1
with:
strings: ${{steps.changedFiles.outputs.added_modified}} ${{steps.changedFiles.outputs.renamed}}
patterns: ${{env.BASE_FILE_PATTERNS}}
- name: 过滤删除的改变文件
id: filterDel
if: ${{steps.changedFiles.outputs.removed}}
uses: iamobj/action-minimatch@v1
with:
strings: ${{steps.changedFiles.outputs.removed}}
patterns: ${{env.BASE_FILE_PATTERNS}}
- name: 上传到七牛云
if: steps.filterUpload.outputs.files
run: |
# 单文件循环上传
for changed_file in ${{steps.filterUpload.outputs.files}}; do
./qshell fput ${{env.QINIU_BUCKET}} $changed_file $changed_file --overwrite
done
- name: 删除七牛云文件
if: steps.filterDel.outputs.files
run: |
# 单文件循环删除
for changed_file in ${{steps.filterDel.outputs.files}}; do
./qshell delete ${{env.QINIU_BUCKET}} $changed_file
done