diff --git a/.github/workflows/deploy-html-storybook-prod.yml b/.github/workflows/deploy-html-storybook-prod.yml index 8e239081a..7bba823d5 100644 --- a/.github/workflows/deploy-html-storybook-prod.yml +++ b/.github/workflows/deploy-html-storybook-prod.yml @@ -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 @@ -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 diff --git a/.github/workflows/deploy-react-storybook-prod.yml b/.github/workflows/deploy-react-storybook-prod.yml index cb1d33bdd..a22feae24 100644 --- a/.github/workflows/deploy-react-storybook-prod.yml +++ b/.github/workflows/deploy-react-storybook-prod.yml @@ -4,8 +4,6 @@ on: push: branches: - main - paths: - - "packages/react/**" env: AWS_S3_BUCKET_NAME: storybook-react-design-system-blocks-gov-ie