This GitHub Action deploys static files to Aliyun (Alibaba Cloud) OSS.
There is a template workflow configuration for you to quickly start with:
mkdir -p .github/workflows
curl -L -o .github/workflows/oss-deploy.yml bit.ly/oss-deployment-action-example
# use your favorite editor to edit .github/workflows/deploy.yml
The following example might cover most of the use cases.
- uses: YangHanlin/oss-deployment-action@v1
with:
# Replace <REGION> with actual region of the bucket, e.g. oss-cn-hangzhou
oss-endpoint: <REGION>.aliyuncs.com
# It is recommended to set the credentials as GitHub Action secrets
oss-accesskey-id: ${{ secrets.OSS_ACCESSKEY_ID }}
oss-accesskey-secret: ${{ secrets.OSS_ACCESSKEY_SECRET }}
# Uncomment the following line only if STS is used
# oss-sts-token: ${{ secrets.OSS_STS_TOKEN }}used only when STS is used
# Replace <BUCKET> and <PATH> with actual bucket name and path
oss-path: oss://<BUCKET>/<PATH>
# Uncomment the following line if you want to specify a different path to deploy files from; otherwise the current working directory is deployed
# local-path: <PATH TO FILE/DIRECTORY>
# Uncomment the following line if you want to ignore files in deployment; otherwise all files except `.git` will be deployed
# ignored-patterns: <GLOBS SEPARATED BY SPACES>
# Uncomment the following line to delete all files under `oss-path` before deployment
# delete-first: true
debug: ${{ secrets.ACTIONS_STEP_DEBUG }}
If you'd like to have more control over the version and configuration of ossutil
, or if you have downloaded and configured ossutil
in previous steps, you can put ossutil
in PATH
to make this action use the existing ossutil
instead of downloading and configuring it again.
- run: |
mkdir -p "$HOME/.local/bin"
wget -O "$HOME/.local/bin/ossutil" https://gosspublic.alicdn.com/ossutil/1.7.14/ossutil64
chmod +x "$HOME/.local/bin/ossutil"
"$HOME/.local/bin/ossutil" config --endpoint=REGION.aliyuncs.com --access-key-id=$OSS_ACCESSKEY_ID --access-key-secret=$OSS_ACCESSKEY_SECRET
# or some other customization
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
# Replace <REGION> with actual region of the bucket, e.g. oss-cn-hangzhou
OSS_ENDPOINT: <REGION>.aliyuncs.com
OSS_ACCESSKEY_ID: ${{ secrets.OSS_ACCESSKEY_ID }}
OSS_ACCESSKEY_SECRET: ${{ secrets.OSS_ACCESSKEY_SECRET }}
- uses: YangHanlin/oss-deployment-action@v1
with:
# Replace <BUCKET> and <PATH> with actual bucket name and path
oss-path: oss://<BUCKET>/<PATH>
# Uncomment the following line if you want to specify a different path to deploy files from; otherwise the current working directory is deployed
# local-path: <PATH TO FILE/DIRECTORY>
# Uncomment the following line if you want to ignore files in deployment; otherwise all files except `.git` will be deployed
# ignored-patterns: <GLOBS SEPARATED BY SPACES>
# Uncomment the following line to delete all files under `oss-path` before deployment
# delete-first: true
debug: ${{ secrets.ACTIONS_STEP_DEBUG }}
Option | Description | Required | Default value |
---|---|---|---|
oss-endpoint |
OSS endpoint | Yes if no ossutil exists in PATH |
|
oss-accesskey-id |
AccessKey ID of user with write access to OSS | Yes if no ossutil exists in PATH |
|
oss-accesskey-secret |
AccessKey secret of the user identified by the previous AccessKey ID | Yes if no ossutil exists in PATH |
|
oss-sts-token |
STS token | Yes if no ossutil exists in PATH and STS is used |
|
oss-path |
Path to the location you'd like to deploy files to, i.e. oss://<BUCKET NAME>/<PATH> |
Yes | |
local-path |
Path to the location you'd like to deploy files from | No | . |
ignored-patterns |
Blob patterns of files (separated by spaces) to ignore in deployment | No | .git |
delete-first |
Whether to delete files under oss-path before deployment |
No | false |
force-setup-ossutil |
Whether to force download and configure even if ossutil is in PATH |
No | false |
cache-ossutil |
Whether to cache downloaded ossutil |
No | false |
debug |
Whether to enable debug logging; recommended to set to ${{ secrets.ACTIONS_STEP_DEBUG }} to align with debug logging option provided by GitHub Actions |
No | false |
- The current version of this action is using
ossutil
to upload files to OSS. It downloads and configuresossutil
with provided credentials automatically by default; but ifossutil
can be found inPATH
, this action will use that copy and assumes it is already configured with proper credentials and endpoint. This is to leave to you the space for additional customization ofossutil
; see this example.
All contents in this repository, unless otherwise noted, are licensed under MIT.
This repository is not affiliated with Alibaba Cloud.