Skip to content

Commit

Permalink
feat: split cd actions for analytics and shared gf-375 (#433)
Browse files Browse the repository at this point in the history
* chore: add cd action to publish analytics script to npm gf-375

* chore: add repository url to analytics package.json gf-375

* chore: update analytics cd action gf-375

* chore: update analytics cd action gf-375

* feat: trigger analytics release gf-375

* feat: update secrets in analytics cd action gf-375

* fix: analytics build path gf-375

* feat: split cd actions for analytics and shared gf-375
  • Loading branch information
liza-veis authored Sep 19, 2024
1 parent 2cd71c0 commit bc730a5
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/cd-analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ jobs:
- name: Publish
working-directory: ${{ env.ARTIFACT_PATH }}
run: |
npm publish --provenance --access public --workspace packages/shared
npm publish --provenance --access public --workspace scripts/analytics
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
103 changes: 103 additions & 0 deletions .github/workflows/cd-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Continuous Delivery Shared

env:
ARTIFACT_NAME: build
ARTIFACT_PATH: ./

on:
workflow_call:
secrets:
NPM_TOKEN:
required: true
workflow_dispatch:

concurrency:
group: cd-${{ github.ref }}
cancel-in-progress: false

jobs:
dependencies:
name: Install Dependencies
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Cache Dependencies
id: cache
uses: actions/cache@v4
with:
path: |
**/node_modules
key: cd-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
cd-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

build:
name: Code Building
needs: dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Restore Dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
key: cd-${{ hashFiles('**/package-lock.json') }}

- name: Code Building
run: |
npm run build:shared
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}

npm-publish:
name: Publish to NPM
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org

- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}

- name: Publish
working-directory: ${{ env.ARTIFACT_PATH }}
run: |
npm publish --provenance --access public --workspace packages/shared
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
13 changes: 11 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
packages_shared_release_created: ${{ steps.release.outputs['packages/shared--release_created'] }}
scripts_analytics_release_created: ${{ steps.release.outputs['scripts/analytics--release_created'] }}
steps:
- name: Code Checkout
Expand Down Expand Up @@ -62,9 +63,17 @@ jobs:
version_label: ${{ github.sha }}
deployment_package: ./build.zip

deploy-analytics:
name: Deploy Analytics Script
publish-shared:
name: Publish Shared Package
needs: release
if: ${{ needs.release.outputs.packages_shared_release_created }}
uses: ./.github/workflows/cd-shared.yml
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

deploy-analytics:
name: Publish Analytics Script
needs: publish-shared
if: ${{ needs.release.outputs.scripts_analytics_release_created }}
uses: ./.github/workflows/cd-analytics.yml
secrets:
Expand Down
4 changes: 2 additions & 2 deletions scripts/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"node": "20.x.x",
"npm": "10.x.x"
},
"main": "./index.js",
"main": "./build/index.js",
"bin": {
"@git-fit/analytics": "./index.js"
"@git-fit/analytics": "./build/index.js"
},
"scripts": {
"lint:type": "npx tsc --noEmit",
Expand Down

0 comments on commit bc730a5

Please sign in to comment.