Skip to content

fix: jinja macro - list error on home page example (#342) #242

fix: jinja macro - list error on home page example (#342)

fix: jinja macro - list error on home page example (#342) #242

name: Deploy React Storybook to AWS S3
on:
push:
branches:
- main
workflow_dispatch: # Allow manual deployment trigger
inputs:
deploy_reason:
description: "Select deployment type"
required: true
default: "Manual Trigger"
jobs:
determine-affected:
runs-on: ubuntu-latest
outputs:
react_affected: ${{ steps.check-affected.outputs.react_affected }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: |
corepack enable
pnpm install --frozen-lockfile --ignore-scripts
- name: Determine affected projects
id: affected
run: |
pnpm nx show projects --affected --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 "@govie-react/storybook" affected.txt; then
echo "react_affected=true" >> $GITHUB_OUTPUT
else
echo "react_affected=false" >> $GITHUB_OUTPUT
fi
build:
runs-on: ubuntu-latest
needs: determine-affected
# Run if html is affected or manually triggered
if: ${{ needs.determine-affected.outputs.react_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: 22
- name: Storybook build
run: |
corepack enable
pnpm install --frozen-lockfile --ignore-scripts
pnpm react:storybook:build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: packages/react/storybook/storybook-static
deploy:
name: Deploy to Amazon S3
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
contents: read
environment: prod
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: build
- name: Setup AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DS_AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Deploy to S3
run: aws s3 sync build/ s3://$AWS_S3_BUCKET_NAME/
env:
AWS_S3_BUCKET_NAME: ${{ vars.REACT_BUCKET_NAME }}
- name: Invalidate Cloudfront
run: aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*'
env:
DISTRIBUTION_ID: ${{ vars.REACT_DISTRIBUTION_ID }}