Skip to content

Test and Deploy Website #6106

Test and Deploy Website

Test and Deploy Website #6106

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Test and Deploy Website
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [master]
schedule:
# Run everyday at 9:00 AM (See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07)
- cron: '0 5 * * *'
# 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"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Get node version
id: node-version
run: |
echo "::set-output name=ver::$(node --version)"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
# use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Cache install
uses: actions/cache@v3
with:
path: |
./node_modules
./doc/node_modules
./website/node_modules
./blog/node_modules
key: ${{ runner.os }}-dep-${{ steps.node-version.outputs.ver }}-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: |
yarn install
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%V")"
shell: bash
- name: Apply docs cache
id: docs-cache
uses: actions/cache@v3
with:
path: |
./scripts/temp
key: ${{ runner.os }}-${{ steps.node-version.outputs.ver }}-docs-${{ hashFiles('website/config/apisix-versions.js') }}-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ steps.node-version.outputs.ver }}-docs-${{ hashFiles('website/config/apisix-versions.js') }}
- name: Sync documents
run: |
yarn prepare-data && git status
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Apply docusaurus cache
id: docusaurus-cache
uses: actions/cache@v3
with:
path: |
./website/.docusaurus
./website/build
./doc/.docusaurus
./doc/build
./blog/en/.docusaurus
./blog/en/build
./blog/zh/.docusaurus
./blog/zh/build
key: ${{ runner.os }}-dep-${{ steps.node-version.outputs.ver }}-docusaurus-${{ hashFiles('website/config/apisix-versions.js') }}-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-dep-${{ steps.node-version.outputs.ver }}-docs-${{ hashFiles('website/config/apisix-versions.js') }}
- name: Build
run: |
yarn build
- name: Update sitemap.xml
run: |
yarn update-sitemap && git status
- name: Deploy to Netlify
uses: ./.github/actions/actions-netlify
if: ${{ false }}
with:
publish-dir: './website/build'
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: '${{ github.event.pull_request.title }}, Deploy from GitHub Actions'
enable-pull-request-comment: true
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 10
- name: Deploy
uses: peaceiris/[email protected]
if: github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event_name == 'schedule'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: website/build
publish_branch: asf-site
force_orphan: true