diff --git a/.github/workflows/deployStorybook.yml b/.github/workflows/deployStorybook.yml new file mode 100644 index 00000000..0de119ec --- /dev/null +++ b/.github/workflows/deployStorybook.yml @@ -0,0 +1,38 @@ +name: Build and Deploy Storybook to Cloudfront + +on: + push: + branches: [develop] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Install dependencies + run: | + npm --version + npm ci --production + + - name: Build Storybook + run: | + npm run build-storybook + + - name: Copy files to S3 + run: | + aws s3 sync --delete ${{ env.DIST }} .storybook-static s3://${{ secrets.S3_BUCKET }} + + - name: Invalidate Cloudfront + run: | + aws cloudfront create-invalidation \ + --distribution-id ${{ env.DIST_ID }} \ + --paths "/*"