Skip to content

Deployment

Deployment #135

Workflow file for this run

name: Deployment
on:
schedule:
- cron: "30 22 * * 2" # https://crontab.guru/#30_22_*_*_2
workflow_dispatch:
defaults:
run:
shell: bash
permissions:
contents: read
# NOTES: For deploy GitHub Pages (deploy the pages)
pages: write
# NOTES: For deploy GitHub Pages (verify the deployment source)
id-token: write
concurrency:
group: deployment
cancel-in-progress: true
env:
RELEASE_BRANCH: release
ACTIVE_BRANCH: main
# Either v1 or v2
DOCS_VERSION: v2
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup rushjs
uses: ./.github/actions/setup-rush
with:
build: true
build-cache: true
- name: Check for missing changelogs
uses: ./.github/actions/run-rush
with:
command: change
args: --verify
- name: Deployment summary
uses: ./.github/actions/run-rush
with:
command: publish
deploy:
# This will enforce deploy applications from main branch only
# however, developer still able to dry-run
# deployment on their feature branch.
#
# We have another protection on environment layers
# however, that will cause deployment workflow
# completed with failure.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: npm-registry
url: https://www.npmjs.com/org/kcws
needs:
- check
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Setup git
uses: ./.github/actions/setup-git
with:
git-email: ${{ secrets.GIT_EMAIL }}
git-username: ${{ secrets.GIT_USERNAME }}
github-token: ${{ secrets.GH_TOKEN }}
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY_BASE64 }}
gpg-fingerprint: ${{ secrets.GPG_FINGERPRINT }}
- name: Setup rushjs
uses: ./.github/actions/setup-rush
with:
build: true
build-cache: false
- name: Deploying packages
uses: ./.github/actions/run-rush
with:
command: publish
args: >
--apply
--target-branch "release"
--publish
--add-commit-details
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Syncback active branch
uses: ./.github/actions/sync-git
with:
base-branch: main
branch: release
- name: Cleanup git
if: always()
uses: ./.github/actions/cleanup-git
with:
gpg-fingerprint: ${{ secrets.GPG_FINGERPRINT }}
deploy-docs:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs:
- deploy
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup rushjs
uses: ./.github/actions/setup-rush
with:
build: true
build-cache: true
- name: Building documentation
uses: ./.github/actions/run-rush
with:
command: docs:${{ env.DOCS_VERSION }}
- name: Compiling documentation
if: env.DOCS_VERSION == 'v1'
uses: actions/jekyll-build-pages@v1
with:
source: ./_docs
destination: ./_site
- name: Uploading document
uses: actions/upload-pages-artifact@v3
with:
path: ./_site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4