Skip to content

Commit

Permalink
Update gitub action
Browse files Browse the repository at this point in the history
  • Loading branch information
samzong committed Sep 17, 2022
1 parent d9520cd commit b167fca
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: deploy-for-main

# Controls when the workflow will run
on:
Expand All @@ -11,14 +11,12 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


env:
UCLOUD_PUBLICKEY : ${{ secrets.UCLOUD_PUBLICKEY }}
UCLOUD_PRIVATEKEY : ${{ secrets.UCLOUD_PRIVATEKEY }}
UCLOUD_REGION : ${{ secrets.UCLOUD_REGION }}
UCLOUD_BUCKET : ${{ secrets.UCLOUD_BUCKET }}


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
Expand All @@ -30,13 +28,25 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required for mkdocs to be able to display pages last update info
- uses: actions/setup-python@v2
with:
python-version: 3.x

# Add ssh private key
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v1
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}

# Install mkdocs-material-insiders
- run: git clone git@github.com:DaoCloud/mkdocs-material-insiders.git mkdocs-material
- run: pip install -e mkdocs-material

# Runs a single command using the runners shell
- run: pip install mkdocs-material \
mkdocs-git-revision-date-plugin \
- run: pip install mkdocs-git-revision-date-plugin \
mkdocs-mermaid2-plugin \
mkdocs-rss-plugin \
mkdocs-minify-plugin \
Expand All @@ -50,11 +60,17 @@ jobs:

# build docs
- run: pwd
- run: echo $UCLOUD_REGION && echo $UCLOUD_BUCKET
- run: mkdocs build -f mkdocs.yml -d public/
- run: mkdocs build -f mkdocs-en.yml -d public/en/

# upload to ucloud bucket
- run: cd public && pwd && python ../scripts/upload-ucloud.py \
public_key=$UCLOUD_PUBLICKEY \
private_key=$UCLOUD_PRIVATEKEY \
region=$UCLOUD_REGION \
bucket=$UCLOUD_BUCKET

# refresh docs site cdn cache
- run: python scripts/refresh_cdn_cache.py \
publickey=$UCLOUD_PUBLICKEY \
privatekey=$UCLOUD_PRIVATEKEY
19 changes: 15 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: deploy-test-for-pr

# Controls when the workflow will run
on:
Expand All @@ -25,13 +25,25 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required for mkdocs to be able to display pages last update info
- uses: actions/setup-python@v2
with:
python-version: 3.x

# Add ssh private key
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v1
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}

# Install mkdocs-material-insiders
- run: git clone git@github.com:DaoCloud/mkdocs-material-insiders.git mkdocs-material
- run: pip install -e mkdocs-material

# Runs a single command using the runners shell
- run: pip install mkdocs-material \
mkdocs-git-revision-date-plugin \
- run: pip install mkdocs-git-revision-date-plugin \
mkdocs-mermaid2-plugin \
mkdocs-rss-plugin \
mkdocs-minify-plugin \
Expand All @@ -42,7 +54,6 @@ jobs:
# add custom plugin with pdf support
- run: pip install git+https://github.com/SAMZONG/mkdocs-with-pdf-support-material-v8


# build docs
- run: pwd
- run: mkdocs build -f mkdocs.yml -d public/
Expand Down
3 changes: 1 addition & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ build-job: # This job runs in the build stage, which runs first.

- python ../scripts/refresh_cdn_cache.py \
publickey=${u_publickey} \
privatekey=${u_privatekey} \
domain=${u_domain}
privatekey=${u_privatekey}
7 changes: 5 additions & 2 deletions scripts/refresh_cdn_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def refresh_cdn_cache(privatekey, publickey, domain):

publickey = argv[1].split('=')[1]
privatekey = argv[2].split('=')[1]
domain = argv[3].split('=')[1]
# domain = argv[3].split('=')[1]

refresh_cdn_cache(privatekey, publickey, domain)
domains = ["http://docs-alpha.daocloud.io/","https://docs-alpha.daocloud.io/"]

for domain in domains:
refresh_cdn_cache(privatekey, publickey, domain)

0 comments on commit b167fca

Please sign in to comment.