This repository has been archived by the owner on Aug 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'latest' into migrate-to-yarn
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Deploy Storybook Preview | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
deploy-storybook-preview: | ||
name: Deploy Storybook Preview | ||
runs-on: ubuntu-latest | ||
env: | ||
BUCKET_DIR: ${{github.event.number}} | ||
PREVIEW_URL: 'http://psammead-preview.tools.bbc.co.uk/${{github.event.number}}' | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Install Node Modules and Build | ||
if: github.event.pull_request.closed != true # Run this step for all PR events except `closed` | ||
run: | | ||
npm run ci:packages | ||
npm run build:storybook | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.STORYBOOK_PREVIEW_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.STORYBOOK_PREVIEW_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-west-1 | ||
|
||
- name: 'Deploy storybook to preview environment' | ||
if: github.event.pull_request.closed != true # Run this step for all PR events except `closed` | ||
run: | | ||
aws s3 sync storybook_dist ${{ secrets.STORYBOOK_PREVIEW_S3_BUCKET }}${{ env.BUCKET_DIR }} --acl public-read | ||
- name: Comment on PR with preview URL | ||
if: github.event.pull_request.closed != true # Run this step for all PR events except `closed` | ||
uses: unsplash/comment-on-pr@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
msg: Checkout your storybook preview here ${{ env.PREVIEW_URL }} | ||
check_for_duplicate_msg: true | ||
|
||
- name: 'Cleaning up storybook preview for PR#${{ env.BUCKET_DIR }}' | ||
if: github.event.pull_request.closed == true # Only run this step when the PR is closed | ||
run: | | ||
aws s3 rm ${{ secrets.STORYBOOK_PREVIEW_S3_BUCKET }}${{ env.BUCKET_DIR }} --recursive |