Browse Source

Add 'vue/.github/workflows/deploy_aliyun_oss'

天问 5 years ago
parent
commit
b6f077bb80
1 changed files with 42 additions and 0 deletions
  1. 42 0
      vue/.github/workflows/deploy_aliyun_oss

+ 42 - 0
vue/.github/workflows/deploy_aliyun_oss

@@ -0,0 +1,42 @@
+name: deploy to aliyun oss
+
+on:
+  push:
+  schedule:
+  - cron:  '30 20 * * *'
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v1
+      with:
+        submodules: true
+    - uses: srt32/git-actions@v0.0.3
+      with:
+        args: git submodule update --init --recursive
+
+	- name: use Node.js 10.x
+      uses: actions/setup-node@v1
+      with:
+        node-version: 10.x
+    - name: npm install
+      run: npm install
+    - name: build
+      run: npm run build
+    # 设置阿里云OSS的 id/secret,存储到 github 的 secrets 中
+    - name: setup aliyun oss
+      uses: manyuanrong/setup-ossutil@master
+      with:
+        endpoint: oss-cn-beijing.aliyuncs.com
+        access-key-id: ${{ secrets.OSS_KEY_ID }}
+        access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
+    - name: 删除冗余文件
+      run: ossutil rm oss://shanyue-blog/assets -rf
+      if: github.event_name == 'schedule'
+    - name: 复制文件到阿里云OSS
+      run: ossutil cp -rf .vuepress/dist oss://shanyue-blog/
+    - name: 设置永久缓存
+      run: ossutil set-meta oss://shanyue-blog/assets cache-control:"max-age=31536000" --update -rf