You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
aliyun-oss-website-action
v1.2.1
deploy website on aliyun OSS(Alibaba Cloud OSS)
将静态网站部署在阿里云OSS
- 在阿里云OSS创建一个存放网站的bucket
- 准备一个域名, 可能需要备案(bucket选择非大陆区域, 可以不备案, 但是如果CDN加速区域包括大陆, 仍然需要备案)
- 在你的网站repo中, 配置github action, 当action触发, 会清除bucket中原有的文件, 上传网站repo生成的资源文件到bucket中
- 通过阿里云OSS的CDN, 可以很方便地加速网站的访问, 支持HTTPS
- name: upload files to OSS
uses: fangbinwei/aliyun-oss-website-action@v1
with:
accessKeyId: ${{ secrets.ACCESS_KEY_ID }}
accessKeySecret: ${{ secrets.ACCESS_KEY_SECRET }}
bucket: your-bucket-name
# e.g. "oss-cn-shanghai.aliyuncs.com", 也可以填写自定义域名(需要配置cname 为 true)
endpoint: ali-oss-endpoint
folder: your-website-output-folder
accessKeyId
: 必填accessKeySecret
: 必填endpoint
: 必填folder
: 必填, repo打包输出的资源文件夹bucket
: 必填,部署网站的bucket, 用于存放网站的资源cname
: 默认false
. 若endpoint
填写自定义域名, 需设置为true
indexPage
: 默认index.html
.网站首页(用于静态页面配置)notFoundPage
: 默认404.html
.网站404页面(用于静态页面配置)skipSetting
: 默认false
, 是否跳过设置静态页面配置htmlCacheControl
: 默认no-cache
imageCacheControl
: 默认max-age=864000
otherCacheControl
: 默认max-age=2592000
exclude
: 不上传folder
下的某些文件/文件夹
为上传的资源默认设置的Cache-Control
如下
资源类型 | Cache-Control |
---|---|
.html | no-cache |
.png/jpg...(图片资源) | max-age=864000(10days) |
other | max-age=2592000(30days) |
若不需要action来设置, 可以配置skipSetting
为true
如果folder
下的某些文件不需要上传
- name: exclude some files
uses: fangbinwei/aliyun-oss-website-action@v1
with:
folder: dist
exclude: |
tmp.txt
tmp/
tmp2/*.txt
tmp2/*/*.txt
# match dist/tmp.txt
# match dist/tmp/
# match dist/tmp2/a.txt
# match dist/tmp2/a/b.txt not match dist/tmp2/tmp3/b.txt
不支持
**
或者
- name: Clean files before upload
run: rm -f dist/tmp.txt
name: deploy vuepress
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
# load repo to /github/workspace
- uses: actions/checkout@v2
with:
repository: fangbinwei/blog
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12'
- run: npm install [email protected] -g
- run: yarn install
# 打包文档命令
- run: yarn docs:build
- name: upload files to OSS
uses: fangbinwei/aliyun-oss-website-action@v1
with:
accessKeyId: ${{ secrets.ACCESS_KEY_ID }}
accessKeySecret: ${{ secrets.ACCESS_KEY_SECRET }}
bucket: "your-bucket-name"
endpoint: "oss-cn-shanghai.aliyuncs.com"
folder: ".vuepress/dist"
具体可以参考本项目的workflow, npm/yarn配合action/cache
加速依赖安装
- name: upload files to OSS
uses: fangbinwei/aliyun-oss-website-action@v1
with:
accessKeyId: ${{ secrets.ACCESS_KEY_ID }}
accessKeySecret: ${{ secrets.ACCESS_KEY_SECRET }}
bucket: website-spa-vue-demo
endpoint: oss-spa-demo.fangbinwei.cn
cname: true
folder: dist
notFoundPage: index.html
htmlCacheControl: no-cache
imageCacheControl: max-age=864001
otherCacheControl: max-age=2592001
TODO
TODO