Skip to content

2020Deeya is running Deploy Package CD #23

2020Deeya is running Deploy Package CD

2020Deeya is running Deploy Package CD #23

name: Deploy Package CD
run-name: ${{ github.actor }} is running Deploy Package CD
on:
push:
branches:
- main
workflow_dispatch:
env:
rid: ${{ github.run_id }}-${{ github.run_number }}
jobs:
initialize:
name: Initialize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Validate Dependencies
id: validate-dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Cache Dependencies
uses: actions/cache@v4
if: steps.validate-dependencies.outputs.cache-hit != 'true'
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
build-automation:
name: Build Automation
needs: initialize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Synchronize Packages
run: yarn
- name: Build Automation
run: yarn telemetry build && yarn automation build:cli
- name: Cache Automation
uses: actions/cache@v4
with:
path: '**/automation/dist'
key: automation-dist-${{ env.rid }}
generate-package-matrix:
name: Generate Package Matrix
needs: build-automation
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.generate-package-matrix.outputs.packages }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Uncache Automation
uses: actions/cache@v4
with:
path: '**/automation/dist'
key: automation-dist-${{ env.rid }}
- name: Synchronize Packages
run: yarn
- name: Update Main Branch
run: |
git fetch origin main --unshallow
- id: generate-package-matrix
name: Generate Package Matrix
run: echo "packages=$(yarn md-automation -- --command get-packages --changed --commit-index 1 --dependent)" >> $GITHUB_OUTPUT
- name: Display Package Matrix
run: echo "generated package matrix - ${{ steps.generate-package-matrix.outputs.packages }}"
build:
name: Build
needs: initialize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Synchronize Packages
run: yarn
- name: Build
run: yarn build
- name: Cache Dist
uses: actions/cache@v4
with:
path: '**/dist'
key: dist-${{ env.rid }}
deploy-npmjs:
name: ( ${{ matrix.package }} ) Deploy - NPMJS
needs: [build, generate-package-matrix]
if: ${{ needs.generate-package-matrix.outputs.packages != '[]' && needs.generate-package-matrix.outputs.packages != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.generate-package-matrix.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Uncache Dist
uses: actions/cache@v4
with:
path: '**/dist'
key: dist-${{ env.rid }}
- name: Synchronize Packages
run: yarn
- name: Update Main Branch
run: |
git fetch origin main --unshallow
- name: Increment Packages
run: yarn md-automation -- --command increment-packages --packages ${{ matrix.package }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Yarn
run: yarn config set npmAuthToken ${{ secrets.NPM_TOKEN_CISCO_MD }}
- name: ( ${{ matrix.package }} ) Deploy - NPMJS
run: yarn workspace ${{ matrix.package }} publish:npmjs
dispatch-telemetry:
name: ( ${{ matrix.package }} ) Dispatch Telemetry
needs: [deploy-npmjs, generate-package-matrix]
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.generate-package-matrix.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Uncache Dist
uses: actions/cache@v4
with:
path: '**/dist'
key: dist-${{ env.rid }}
- name: Synchronize Packages
run: yarn
- name: Update Main Branch
run: |
git fetch origin main --unshallow
- name: Dispatch Telemetry ( ${{ matrix.package }} )
run: yarn md-automation -- --command dispatch-telemetry --packages ${{ matrix.package }}
env:
MOMENTUM_METRICS_API_KEY: ${{ secrets.MOMENTUM_METRICS_API_KEY }}
create-release:
name: ( ${{ matrix.package }} ) Create Release
needs: [deploy-npmjs, generate-package-matrix]
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.generate-package-matrix.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Uncache Dependencies
uses: actions/cache@v4
with:
path: |
node_modules
packages/**/node_modules
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Uncache Dist
uses: actions/cache@v4
with:
path: '**/dist'
key: dist-${{ env.rid }}
- name: Synchronize Packages
run: yarn
- name: Update Main Branch
run: git fetch origin main --unshallow
- name: Create Release ( ${{ matrix.package }} )
run: yarn md-automation -- --command create-release --packages ${{ matrix.package }} --since origin/main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}