Merge branch 'staging' into next #3472
This file contains hidden or 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: Deploy | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - alpha | |
| - beta | |
| - production | |
| - staging | |
| - next | |
| paths: | |
| - 'apps/dialtone-documentation/docs/**' | |
| - 'packages/dialtone-css/**/*.less' | |
| - 'packages/dialtone-css/postcss/*.cjs' | |
| - 'packages/dialtone-css/gulpfile.cjs' | |
| - 'packages/dialtone-emojis/src/**' | |
| - 'packages/dialtone-icons/src/**' | |
| - 'packages/dialtone-icons/gulpfile.cjs' | |
| - 'packages/dialtone-tokens/*.js' | |
| - 'packages/dialtone-tokens/postcss/**' | |
| - 'packages/dialtone-tokens/themes/**' | |
| - 'packages/dialtone-tokens/tokens/**' | |
| - 'packages/dialtone-tokens/gulpfile.cjs' | |
| - 'packages/dialtone-vue/**/*.vue' | |
| - 'packages/dialtone-vue/**/*.*js' | |
| - 'packages/dialtone-vue/**/*.stories.js' | |
| - 'packages/combinator/src/**' | |
| - '!**/*.test.*js' | |
| pull_request: | |
| paths: | |
| - 'apps/dialtone-documentation/docs/**' | |
| - 'packages/dialtone-css/**/*.less' | |
| - 'packages/dialtone-css/postcss/*.cjs' | |
| - 'packages/dialtone-css/gulpfile.cjs' | |
| - 'packages/dialtone-emojis/src/**' | |
| - 'packages/dialtone-icons/src/**' | |
| - 'packages/dialtone-icons/gulpfile.cjs' | |
| - 'packages/dialtone-tokens/*.js' | |
| - 'packages/dialtone-tokens/postcss/**' | |
| - 'packages/dialtone-tokens/themes/**' | |
| - 'packages/dialtone-tokens/tokens/**' | |
| - 'packages/dialtone-tokens/gulpfile.cjs' | |
| - 'packages/dialtone-vue/**/*.vue' | |
| - 'packages/dialtone-vue/**/*.*js' | |
| - 'packages/dialtone-vue/**/*.stories.js' | |
| - 'packages/combinator/src/**' | |
| - '!**/*.test.*js' | |
| env: | |
| HUSKY: 0 | |
| BASE_URL: ${{ github.event_name == 'pull_request' && format('deploy-previews/pr-{0}/', github.event.pull_request.number) || (github.ref_name != 'production' && format('{0}/', github.ref_name)) || '' }} | |
| DIALTONE_BUCKET_DIRECTORY: dialtone.dialpad.com | |
| DIALTONE_VUE_3_BUCKET_DIRECTORY: dialtone.dialpad.com/vue | |
| concurrency: | |
| group: "${{ github.workflow }}-${{ github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| filter-actions: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| packages: ${{ steps.filter.outputs.changes }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Filter actions by path | |
| uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| base: ${{ github.ref }} | |
| list-files: 'json' | |
| filters: | | |
| dialtone-documentation: | |
| - 'apps/dialtone-documentation/docs/**' | |
| - 'packages/dialtone-css/**/*.less' | |
| - 'packages/dialtone-css/postcss/*.cjs' | |
| - 'packages/dialtone-css/gulpfile.cjs' | |
| - 'packages/dialtone-emojis/src/**' | |
| - 'packages/dialtone-icons/src/**' | |
| - 'packages/dialtone-icons/gulpfile.cjs' | |
| - 'packages/dialtone-tokens/*.js' | |
| - 'packages/dialtone-tokens/postcss/**' | |
| - 'packages/dialtone-tokens/themes/**' | |
| - 'packages/dialtone-tokens/tokens/**' | |
| - 'packages/dialtone-tokens/gulpfile.cjs' | |
| - 'packages/dialtone-vue/{common,components,directives,localization,recipes}/**/!(*.story.vue|*.test.js|*.stories.js)' | |
| - 'packages/combinator/src/**' | |
| dialtone-vue: | |
| - 'packages/dialtone-css/**/*.less' | |
| - 'packages/dialtone-css/postcss/*.cjs' | |
| - 'packages/dialtone-css/gulpfile.cjs' | |
| - 'packages/dialtone-emojis/src/**' | |
| - 'packages/dialtone-icons/src/**' | |
| - 'packages/dialtone-icons/gulpfile.cjs' | |
| - 'packages/dialtone-tokens/*.js' | |
| - 'packages/dialtone-tokens/postcss/**' | |
| - 'packages/dialtone-tokens/themes/**' | |
| - 'packages/dialtone-tokens/tokens/**' | |
| - 'packages/dialtone-tokens/gulpfile.cjs' | |
| - 'packages/dialtone-vue/**' | |
| 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 | |
| if: ${{ github.event_name == 'push' }} | |
| uses: octokit/request-action@v2.x | |
| with: | |
| route: GET /orgs/dialpad/members/${{ github.actor }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.DIALTONE_CI_TOKEN }} | |
| deploy: | |
| needs: [ check-dialpad-member, filter-actions ] | |
| name: Deploy sites | |
| if: ${{ needs.filter-actions.outputs.packages != '[]' }} | |
| env: | |
| BUCKET_CLEANUP_EXCLUDE: '/alpha/|/beta/|/deploy-previews/|/staging/|/next/|/vue/' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package: ${{ fromJSON(needs.filter-actions.outputs.packages) }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| packages: read | |
| steps: | |
| - name: Checkout | |
| if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | |
| uses: actions/checkout@v4 | |
| - name: Checkout PR | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: "refs/pull/${{ github.event.pull_request.number }}/merge" | |
| - name: Setup Environment | |
| uses: ./.github/actions/setup-environment | |
| # ------------------------------ # | |
| # Expand corresponding variables # | |
| # ------------------------------ # | |
| - name: Expand variables | |
| id: expand | |
| env: | |
| DIALTONE_DIST_DIRECTORY: apps/dialtone-documentation/docs/.vuepress/dist | |
| DIALTONE_VUE_3_DIST_DIRECTORY: packages/dialtone-vue/storybook-static | |
| run: | | |
| if [[ ${{ matrix.package }} == 'dialtone-documentation' ]]; then | |
| echo "VUEPRESS_BASE_URL=/$BASE_URL" >> $GITHUB_ENV; | |
| echo "source_directory=$DIALTONE_DIST_DIRECTORY" >> $GITHUB_OUTPUT; | |
| echo "dest_directory=$DIALTONE_BUCKET_DIRECTORY/$BASE_URL" >> $GITHUB_OUTPUT; | |
| echo "build_command=dialtone-documentation:build" >> $GITHUB_OUTPUT; | |
| elif [[ ${{ matrix.package }} == 'dialtone-vue' ]]; then | |
| echo "source_directory=$DIALTONE_VUE_3_DIST_DIRECTORY" >> $GITHUB_OUTPUT; | |
| echo "dest_directory=$DIALTONE_VUE_3_BUCKET_DIRECTORY/$BASE_URL" >> $GITHUB_OUTPUT; | |
| echo "build_command=dialtone-vue:build-storybook" >> $GITHUB_OUTPUT; | |
| fi | |
| # ---------- # | |
| # Build docs # | |
| # ---------- # | |
| - name: Build ${{ matrix.package }} site | |
| run: pnpm nx run --verbose ${{steps.expand.outputs.build_command}} | |
| # --------- # | |
| # 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 bucket # | |
| # -------------- # | |
| - name: Clean up bucket | |
| continue-on-error: true | |
| run: > | |
| gcloud storage ls ${{ format('gs://{0}', steps.expand.outputs.dest_directory) }} | | |
| grep -v -E "${{ env.BUCKET_CLEANUP_EXCLUDE }}" | | |
| gcloud storage rm --recursive --read-paths-from-stdin | |
| # ---------- # | |
| # GCP Upload # | |
| # ---------- # | |
| - name: Upload to GCP | |
| uses: google-github-actions/upload-cloud-storage@v2 | |
| with: | |
| path: ${{ steps.expand.outputs.source_directory }} | |
| destination: ${{ steps.expand.outputs.dest_directory }} | |
| parent: false | |
| add-preview-ready-message: | |
| needs: [ filter-actions, deploy ] | |
| if: ${{ github.event_name == 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Add comment | |
| uses: mshick/add-pr-comment@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| message: | | |
| ✔️ Deploy previews ready! | |
| ${{ contains(needs.filter-actions.outputs.packages, 'dialtone-documentation') && format('😎 Dialtone documentation preview: https://{0}/{1}', env.DIALTONE_BUCKET_DIRECTORY, env.BASE_URL) || '' }} | |
| ${{ contains(needs.filter-actions.outputs.packages, 'dialtone-vue') && format('😎 Dialtone-vue preview: https://{0}/{1}', env.DIALTONE_VUE_3_BUCKET_DIRECTORY, env.BASE_URL) || '' }} | |
| message-id: 'deploy-preview-message' | |
| refresh-message-position: true |