Skip to content

Commit

Permalink
ci: nx affect usage on html storybook deployment and workflow added f…
Browse files Browse the repository at this point in the history
…or manual deployment
  • Loading branch information
hamza14khan committed Aug 26, 2024
1 parent c354d63 commit e3a85b9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
59 changes: 53 additions & 6 deletions .github/workflows/deploy-html-storybook-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,73 @@ on:
push:
branches:
- main
paths:
- "packages/html/**"
workflow_dispatch: # Allow manual deployment trigger
inputs:
deploy_reason:
description: "Select deployment type"
required: true
default: "Manual Trigger"

env:
AWS_S3_BUCKET_NAME: storybook-html-design-system-blocks-gov-ie

jobs:
determine-affected:
runs-on: ubuntu-latest
outputs:
html_affected: ${{ steps.check-affected.outputs.html_affected }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Install dependencies
run: |
corepack enable
pnpm install --frozen-lockfile --ignore-scripts
- name: Determine affected projects
id: affected
run: |
npx nx affected:libs --base=origin/main~1 --head=HEAD > affected.txt
cat affected.txt
- name: Set environment output if HTML package is affected
id: check-affected
run: |
if grep -q "html" affected.txt; then
echo "html_affected=true" >> $GITHUB_ENV
echo "::set-output name=html_affected::true"
else
echo "html_affected=false" >> $GITHUB_ENV
echo "::set-output name=html_affected::false"
fi
build:
runs-on: ubuntu-latest
needs: determine-affected
# Run if html is affected or manually triggered
if: ${{ needs.determine-affected.outputs.html_affected == 'true' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Storybook build
- name: Install dependencies
run: |
corepack enable
corepack enable
pnpm install --frozen-lockfile --ignore-scripts
pnpm html:storybook:build
- name: Storybook build
run: pnpm html:storybook:build

- name: Upload artifact
uses: actions/upload-artifact@v3.1.2
Expand All @@ -37,13 +82,15 @@ jobs:
name: Deploy to Amazon S3
runs-on: ubuntu-latest
needs: build
# Run if html is affected or manually triggered
if: ${{ needs.determine-affected.outputs.html_affected == 'true' || github.event_name == 'workflow_dispatch' }}
permissions:
id-token: write
contents: read
environment: prod
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v3.0.2
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/deploy-react-storybook-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
paths:
- "packages/react/**"

env:
AWS_S3_BUCKET_NAME: storybook-react-design-system-blocks-gov-ie
Expand Down

0 comments on commit e3a85b9

Please sign in to comment.