Skip to content

revert: NO-JIRA use require for json imports (#454) #1055

revert: NO-JIRA use require for json imports (#454)

revert: NO-JIRA use require for json imports (#454) #1055

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
push:
branches:
- alpha
- beta
- legacy
- next
- production
- staging
paths:
- 'packages/**'
- 'apps/**'
env:
HUSKY: 0
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
filter-actions:
runs-on: ubuntu-latest
outputs:
dialtone: ${{ steps.filter.outputs.dialtone }}
dialtone-vue-2: ${{ steps.filter.outputs.dialtone-vue-2 }}
dialtone-vue-3: ${{ steps.filter.outputs.dialtone-vue-3 }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter actions by path
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
dialtone:
- 'apps/dialtone-documentation/**'
- 'packages/**'
dialtone-vue-2:
- 'packages/**'
dialtone-vue-3:
- 'packages/**'
get-branch-name:
runs-on: ubuntu-latest
outputs:
current_branch: ${{ steps.branch-name.outputs.current_branch }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
check-dialpad-member:
runs-on: ubuntu-latest
steps:
# Will prevent the rest of the steps from running on fail
- name: Check if user is a dialpad member
uses: octokit/[email protected]
with:
route: GET /orgs/dialpad/members/${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.DIALTONE_CI_TOKEN }}
deploy:
name: Deploy sites
needs: [check-dialpad-member, get-branch-name, filter-actions]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
VUEPRESS_BASE_URL: ${{ github.ref == 'refs/heads/production' && '/' || format('/{0}/', needs.get-branch-name.outputs.current_branch) }}
DIALTONE_BUCKET_DIRECTORY: dialtone.dialpad.com${{ github.ref == 'refs/heads/production' && '/' || format('/{0}/', needs.get-branch-name.outputs.current_branch) }}
DIALTONE_VUE_2_BUCKET_DIRECTORY: dialtone.dialpad.com/vue${{ github.ref == 'refs/heads/production' && '/' || format('/{0}/', needs.get-branch-name.outputs.current_branch) }}
DIALTONE_VUE_3_BUCKET_DIRECTORY: dialtone.dialpad.com/vue3${{ github.ref == 'refs/heads/production' && '/' || format('/{0}/', needs.get-branch-name.outputs.current_branch) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Use pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: "${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}"
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
# ---------- #
# Build docs #
# ---------- #
- name: Build documentation sites
run: pnpm nx run-many --verbose --target=build-docs --projects=dialtone-documentation,dialtone-vue2,dialtone-vue3
# --------- #
# Setup GCP #
# --------- #
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.DIALTONE_GCP_WIP }}
service_account: ${{ secrets.DIALTONE_GCP_SA }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
# ------------------ #
# Cleanup production #
# ------------------ #
- name: Clean up bucket Dialtone
if: ${{ github.ref == 'refs/heads/production' }}
run: >
gcloud storage ls ${{ format('gs://{0}', env.DIALTONE_BUCKET_DIRECTORY) }} |
grep -v -E '/alpha/|/beta/|/legacy/|/next/|/deploy-previews/|/vue/|/vue3/|/staging/' |
gcloud storage rm --recursive --read-paths-from-stdin
- name: Clean up bucket Dialtone Vue 2
if: ${{ github.ref == 'refs/heads/production' }}
run: >
gcloud storage ls ${{ format('gs://{0}', env.DIALTONE_VUE_2_BUCKET_DIRECTORY) }} |
grep -v -E '/alpha/|/beta/|/legacy/|/next/|/deploy-previews/|/staging/' |
gcloud storage rm --recursive --read-paths-from-stdin
- name: Clean up bucket Dialtone Vue 3
if: ${{ github.ref == 'refs/heads/production' }}
run: >
gcloud storage ls ${{ format('gs://{0}', env.DIALTONE_VUE_3_BUCKET_DIRECTORY) }} |
grep -v -E '/alpha/|/beta/|/legacy/|/next/|/deploy-previews/|/staging/' |
gcloud storage rm --recursive --read-paths-from-stdin
# ---------------------- #
# Cleanup other branches #
# ---------------------- #
- name: Clean up Dialtone ${{ needs.get-branch-name.outputs.current_branch }}
if: ${{ github.ref != 'refs/heads/production' }}
continue-on-error: true
run: gcloud storage rm --recursive ${{ format('gs://{0}', env.DIALTONE_BUCKET_DIRECTORY) }}
- name: Clean up Dialtone Vue 2 ${{ needs.get-branch-name.outputs.current_branch }}
if: ${{ github.ref != 'refs/heads/production' }}
continue-on-error: true
run: gcloud storage rm --recursive ${{ format('gs://{0}', env.DIALTONE_VUE_2_BUCKET_DIRECTORY) }}
- name: Clean up Dialtone Vue 3 ${{ needs.get-branch-name.outputs.current_branch }}
if: ${{ github.ref != 'refs/heads/production' }}
continue-on-error: true
run: gcloud storage rm --recursive ${{ format('gs://{0}', env.DIALTONE_VUE_3_BUCKET_DIRECTORY) }}
# ---------- #
# GCP Upload #
# ---------- #
- name: Upload Dialtone to GCP
uses: google-github-actions/upload-cloud-storage@v2
with:
path: apps/dialtone-documentation/docs/.vuepress/dist
destination: ${{ env.DIALTONE_BUCKET_DIRECTORY }}
parent: false
- name: Upload Dialtone-vue 2 to GCP
uses: google-github-actions/upload-cloud-storage@v2
with:
path: packages/dialtone-vue2/storybook-static
destination: ${{ env.DIALTONE_VUE_2_BUCKET_DIRECTORY }}
parent: false
- name: Upload Dialtone-vue 3 to GCP
uses: google-github-actions/upload-cloud-storage@v2
with:
path: packages/dialtone-vue3/storybook-static
destination: ${{ env.DIALTONE_VUE_3_BUCKET_DIRECTORY }}
parent: false