Skip to content

create-wapi-app-v0.1.1 #18

create-wapi-app-v0.1.1

create-wapi-app-v0.1.1 #18

name: Documentation build
on:
# trigger this workflow to generate documentation for new version release
release:
types:
- created
# manual workflow dispatch
workflow_dispatch:
inputs:
ref:
description: "The branch, tag or SHA to checkout"
required: true
ref_type:
type: choice
description: "Branch or tag"
options:
- branch
- tag
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-and-upload-docs:
environment: Production
name: Build & upload documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: User Node.js LTS
uses: actions/setup-node@v2
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
with:
run_install: false
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Generate docs
run: pnpm run doc:gen
- name: Checkout docs repository
uses: actions/checkout@v3
with:
repository: "sarthakjdev/wapijs-docs-json"
token: ${{ secrets.WAPIJS_DOCS_ACCESS_TOKEN }}
path: "out"
- name: Extract package and semantic version from release tag
if: ${{ github.ref_type == 'tag' }}
id: extract-tag
uses: ./.github/workflows/format-tag
with:
tag: ${{ github.ref_name }}
- name: Move docs to correct directory
if: ${{ github.ref_type == 'tag' }}
env:
PACKAGE: ${{ steps.extract-tag.outputs.package }}
SEMVER: ${{ steps.extract-tag.outputs.semver }}
run: |
mkdir -p "out/wapi.js"
mv "packages/wapi.js/docs/docs.api.json" "out/wapi.js/${SEMVER}.json"
- name: Move docs to correct directory
if: ${{ github.ref_type == 'branch' }}
run: |
input_string="$GITHUB_REF_NAME"
if [[ "$input_string" == *"/"* ]]; then
documentation_file_name=$(echo "$input_string" | cut -d'/' -f2)
echo "Extracted: $documentation_file_name"
else
documentation_file_name="$GITHUB_REF_NAME"
echo "No slash in the string, nothing to extract."
fi
mkdir -p "out/wapi.js"
mv "packages/wapi.js/docs/docs.api.json" "out/wapi.js/${documentation_file_name}.json"
- name: Commit and push
run: |
cd out
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true
git push
deploy-docutmentation:
environment: Production
timeout-minutes: 15
needs: build-and-upload-docs
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: User Node.js LTS
uses: actions/setup-node@v2
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
- name: Install Vercel CLI
run: pnpm -g add vercel@canary
- name: Install Dependencies
run: pnpm install --frozen-lockfile
working-directory: apps/wapijs.co
- name: Build
run: pnpm run build
working-directory: apps/wapijs.co
- name: Trigger Production Deployment
run: vercel deploy -y --prod --token=${{ secrets.VERCEL_TOKEN }} > deployment-url.txt
- name: Deployment Failure Alert
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: general
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: "production deployment failed, check [HERE](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
SLACK_TITLE: "🚨🚨🚨 [WAPIJS.CO] MASTER BRANCH DEPLOYMENT FAILED 🚨🚨🚨"
SLACK_USERNAME: sarthakjdev
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}