Deployment #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deployment | |
on: | |
schedule: | |
- cron: "30 22 * * 2" # https://crontab.guru/#30_22_*_*_2 | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
pages: write | |
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: | |
verifying: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup rushjs | |
uses: ./.github/actions/setup-rush | |
with: | |
install: true | |
cache-build: false | |
- name: Checking for missing changelogs | |
uses: ./.github/actions/run-rush | |
with: | |
command: change | |
args: --verify | |
- name: Deployment summary | |
uses: ./.github/actions/run-rush | |
with: | |
command: publish | |
deploying: | |
# 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: | |
- verifying | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
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: | |
install: true | |
cache-build: false | |
- name: Building packages | |
uses: ./.github/actions/run-rush | |
with: | |
command: build | |
- 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: 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@v1 | |
with: | |
path: ./_site | |
retention-days: "1" | |
- 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 }} | |
deploying-docs: | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: | |
- deploying | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 |