deploy to aliyun oss #2536
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy to aliyun oss | |
on: | |
push: | |
barches: | |
- master | |
schedule: | |
- cron: '50 20 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 切代码到 runner | |
- uses: actions/checkout@v1 | |
with: | |
submodules: true | |
- name: use Node.js 14.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
- uses: bahmutov/npm-install@v1 | |
- 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-question/assets -rf | |
if: github.event_name == 'schedule' | |
- name: cp files to aliyun | |
run: | | |
ossutil cp -rf --meta Cache-Control:no-cache .vuepress/dist oss://shanyue-question/ | |
ossutil cp -rf --meta Cache-Control:max-age=31536000 .vuepress/dist/assets oss://shanyue-question/assets |