Skip to content

Pine Continuous Deployment #48

Pine Continuous Deployment

Pine Continuous Deployment #48

name: "Pine Continuous Deployment"
on:
## We will uncomment this when we settle on a deployment schedule
# schedule:
# - cron: '00 04 * * 1' # 4 am UTC (9 am CST) Monday
workflow_call:
inputs:
preid:
description: 'The prerelease id used when doing a prerelease. e.g prerelease, premajor, preminor, etc.'
type: string
default: ''
ref:
description: 'This could be a branch name, tag, or a SHA.'
type: string
default: ''
tag:
description: 'The tag to publish on NPM.'
required: true
type: string
version:
description: 'The type of version to release.'
required: true
type: string
secrets:
NPM_TOKEN:
required: true
workflow_dispatch:
inputs:
preid:
type: string
description: Which prerelease id should be used? This is only needed when a version is "prepatch", "preminor", "premajor", or "prerelease".
default: ''
# - ''
# - alpha
# - beta
# - rc
# - next
ref:
type: string
description: The branch name, tag, or SHA to be checked out. This can also be left blank.
default: ''
tag:
type: choice
required: true
description: Which npm tag should this be published to?
options:
- latest
- next
- dev
version:
type: choice
description: Which version should be published?
options:
- ''
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
jobs:
build-core:
runs-on: ubuntu-latest
steps:
- name: Set SHA
uses: nrwl/nx-set-shas@v4
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: ./.github/workflows/actions/setup
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Install Dependencies
run: npm ci --legacy-peer-deps
shell: bash
- name: Build Core
uses: ./.github/workflows/actions/build-core
build-react:
runs-on: ubuntu-latest
steps:
- name: Set SHA
uses: nrwl/nx-set-shas@v4
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: ./.github/workflows/actions/setup
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Build React
uses: ./.github/workflows/actions/build-react
build-doc-components:
runs-on: ubuntu-latest
steps:
- name: Set SHA
uses: nrwl/nx-set-shas@v4
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: ./.github/workflows/actions/setup
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Build Doc Components
uses: ./.github/workflows/actions/build-doc-components
release:
permissions:
contents: write
id-token: write
needs: [build-core, build-react, build-doc-components]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Latest
run: git pull
shell: bash
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Verify NPM Cache
shell: bash
run: npm cache verify
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> $GITHUB_ENV
- name: Configure user
run: |
git config user.name "DSS Automation Bot"
git config user.email "dev+github-bot@kajabi.com"
shell: bash
# - name: Restore Core built Cache
# uses: ./.github/workflows/actions/download-archive
# with:
# name: pine-core
# path: libs/core
# filename: CoreBuild.zip
# - name: Restore React built Cache
# uses: ./.github/workflows/actions/download-archive
# with:
# name: pine-react
# path: libs/react
# filename: ReactBuild.zip
# - name: Restore Doc Components built cache
# uses: ./.github/workflows/actions/download-archive
# with:
# name: pine-doc-components
# path: libs/doc-components
# filename: DocComponentsBuild.zip
- name: Install Dependencies
run: npm ci --ignore-scripts
shell: bash
- name: Build All
run: npx nx run-many --target=build --all
shell: bash
- name: Prepare NPM Token
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release
if: ${{ inputs.version == '' }}
run: npx nx release --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
### Steps below are used for releasing a specified version type (major, minor, patch, etc.)
- name: Release with Input Version
if: ${{ inputs.version != '' }}
run: npx nx release ${{ inputs.version }} --preid ${{ inputs.preid }} --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
- name: Report pine production deployment to GetDX
if: ${{ success() }}
uses: Kajabi/getdx-deployment-identifier-action@main
with:
getdx-instance-name: 'kajabi'
getdx-token: ${{ secrets.GETDX_DEPLOYMENT_TOKEN }}
service-name: 'pine'
send-slack-notification:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest
run: git pull
shell: bash
- name: Fetch latest tags
run: git fetch --tags
shell: bash
- name: Setup ENV Vars
run: |
# Get the latest git tag (which is the version just released)
VERSION=$(git describe --tags --abbrev=0)
CURRENT_DATE=$(date +'%B %d, %Y')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "CURRENT_DATE=$CURRENT_DATE" >> $GITHUB_ENV
echo "RELEASE_URL=https://github.com/${{ github.repository }}/releases/tag/$VERSION" >> $GITHUB_ENV
shell: bash
- name: Send Slack Notification
uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
DATE: ${{ env.CURRENT_DATE }}
RELEASE_URL: ${{ env.RELEASE_URL }}
VERSION: ${{ env.VERSION }}
with:
channel-id: ${{ vars.SLACK_CHANNEL_NAME }}
payload-file-path: "./.github/workflows/slack_payloads/release-info.json"