chore(tooling): migrate from circleci to github actions for all workspaces #107
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 CD | ||
| run-name: ${{ github.actor }} is running Deploy CD | ||
| on: | ||
| push: | ||
| branches: # White-list of deployable tags and branches. Note that all white-listed branches cannot include any `/` characters | ||
| - ccwidgets | ||
| # - next uncomment when ready to deploy next | ||
| env: | ||
| rid: ${{ github.run_id }}-${{ github.run_number }} | ||
| token: ${{ secrets.NPM_TOKEN }} | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| GIT_AUTHOR_NAME: ${{ github.actor }} | ||
| GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com | ||
| jobs: | ||
| build-and-analyze: | ||
| name: Build and Determine Changed Packages | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| node-changed: ${{ steps.generate-package-matrix-node-changed.outputs.node-changed }} | ||
| node-recursive: ${{ steps.generate-package-matrix-node-recursive.outputs.node-recursive }} | ||
| yarn-changed: ${{ steps.generate-package-matrix-yarn-changed.outputs.yarn-changed }} | ||
| yarn-recursive: ${{ steps.generate-package-matrix-yarn-recursive.outputs.yarn-recursive }} | ||
| steps: | ||
| - name: Checkout Project | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Fetch all history for package comparison | ||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: "yarn" | ||
| - name: Install Dependencies | ||
| uses: actions/cache@v4 | ||
| id: cache-dependencies | ||
| with: | ||
| path: "**/node_modules" | ||
| key: node-modules-${{ hashFiles('./yarn.lock') }} | ||
| - name: Install if cache miss | ||
| if: steps.cache-dependencies.outputs.cache-hit != 'true' | ||
| run: yarn install --immutable | ||
| - name: Build meetings widget | ||
| run: yarn workspace @webex/widgets run build:src | ||
| - name: Build cc widgets | ||
| run: yarn run build:prod | ||
| - name: Cache Build Outputs | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: "**/dist" | ||
| key: dist-${{ env.rid }} | ||
| # Generate package matrix for changed packages | ||
| - id: generate-package-matrix-node-changed | ||
| name: Generate Package Matrix (Node Changed) | ||
| run: echo "node-changed=$(yarn package-tools list --mode node --since ${{ github.event.before }})" >> $GITHUB_OUTPUT | ||
| - id: generate-package-matrix-node-recursive | ||
| name: Generate Package Matrix (Node Recursive) | ||
| run: echo "node-recursive=$(yarn package-tools list --mode node --recursive --since ${{ github.event.before }})" >> $GITHUB_OUTPUT | ||
| - id: generate-package-matrix-yarn-changed | ||
| name: Generate Package Matrix (Yarn Changed) | ||
| run: echo "yarn-changed=$(yarn package-tools list --since ${{ github.event.before }})" >> $GITHUB_OUTPUT | ||
| - id: generate-package-matrix-yarn-recursive | ||
| name: Generate Package Matrix (Yarn Recursive) | ||
| run: echo "yarn-recursive=$(yarn package-tools list --recursive --since ${{ github.event.before }})" >> $GITHUB_OUTPUT | ||
| - name: Display Package Matrix | ||
| run: | | ||
| echo "Changed packages (node): ${{ steps.generate-package-matrix-node-changed.outputs.node-changed }}" | ||
| echo "Changed packages + dependents (node): ${{ steps.generate-package-matrix-node-recursive.outputs.node-recursive }}" | ||
| echo "Changed packages (yarn): ${{ steps.generate-package-matrix-yarn-changed.outputs.yarn-changed }}" | ||
| echo "Changed packages + dependents (yarn): ${{ steps.generate-package-matrix-yarn-recursive.outputs.yarn-recursive }}" | ||
| publish-npm: | ||
| name: Publish to NPM | ||
| needs: build-and-analyze | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Project | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: "yarn" | ||
| - name: Restore Dependencies Cache | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: "**/node_modules" | ||
| key: node-modules-${{ hashFiles('./yarn.lock') }} | ||
| - name: Restore Build Outputs | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: "**/dist" | ||
| key: dist-${{ env.rid }} | ||
| - name: Configure NPM Authentication | ||
| run: echo "npmAuthToken: ${{ env.token }}" >> ~/.yarnrc.yml | ||
| - name: Sync and Increment Package Versions | ||
| run: | | ||
| yarn package-tools sync --tag ${GITHUB_REF##*/} | ||
| yarn package-tools increment --packages ${{ needs.build-and-analyze.outputs.node-recursive }} --tag ${GITHUB_REF##*/} | ||
| - name: Rebuild Changed Packages | ||
| run: yarn run build:prod | ||
| - name: Deploy Packages (Dry Run) | ||
| run: yarn workspaces foreach --from '${{ needs.build-and-analyze.outputs.yarn-recursive }}' --verbose run deploy:npm --dry-run --access public --tag ${GITHUB_REF##*/} | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||