This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore storybook for PR review and version publish (#168)
* Bump dependencies with minor changes * Remove discontinued dependencies
- Loading branch information
Daniel Sanchez
authored
Nov 22, 2021
1 parent
9ccd07c
commit 04fb1a4
Showing
48 changed files
with
2,013 additions
and
2,035 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
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,86 @@ | ||
name: Deploy storybook | ||
|
||
on: | ||
# Pull request hook without any config. Launches for every pull request | ||
pull_request: | ||
# Launches build when release is published | ||
release: | ||
types: [published] | ||
|
||
env: | ||
REPO_NAME_ALPHANUMERIC: safereactcomponents | ||
|
||
jobs: | ||
deploy: | ||
name: Deployment | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Node.js setup | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
|
||
- name: Env dependencies setup | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get -y install python3-pip python3-dev | ||
pip install awscli --upgrade --user | ||
- name: Yarn install | ||
run: | | ||
mkdir .yarncache | ||
yarn install --cache-folder ./.yarncache --frozen-lockfile | ||
rm -rf .yarncache | ||
yarn cache clean | ||
- name: Build storybook | ||
run: yarn build-storybook | ||
|
||
- 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: ${{ secrets.AWS_DEFAULT_REGION }} | ||
|
||
# Script to deploy Pull Requests | ||
- run: bash ./scripts/github/deploy_pull_request.sh | ||
if: success() && github.event.number | ||
env: | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
REVIEW_BUCKET_NAME: ${{ secrets.AWS_REVIEW_BUCKET_NAME }} | ||
|
||
- name: 'PRaul: Comment PR with app URLs' | ||
uses: mshick/add-pr-comment@v1 | ||
with: | ||
message: | | ||
:books: [Storybook review](${{ env.REVIEW_FEATURE_URL }}) | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
repo-token-user-login: 'github-actions[bot]' | ||
if: success() && github.event.number | ||
env: | ||
REVIEW_FEATURE_URL: https://pr${{ github.event.number }}--safereactcomponents.review.gnosisdev.com | ||
|
||
|
||
# Script to prepare production deployments | ||
- run: bash ./scripts/github/prepare_production_deployment.sh | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
PROD_DEPLOYMENT_HOOK_TOKEN: ${{ secrets.PROD_DEPLOYMENT_HOOK_TOKEN }} | ||
PROD_DEPLOYMENT_HOOK_URL: ${{ secrets.PROD_DEPLOYMENT_HOOK_URL }} | ||
VERSION_TAG: ${{ github.event.release.tag_name }} |
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
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
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
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
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ module.exports = { | |
'@babel/preset-typescript', | ||
'@babel/preset-react', | ||
], | ||
plugins: ['react-docgen'], | ||
}; |
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
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,34 @@ | ||
#!/bin/bash | ||
|
||
BUILD_DIR='storybook-static' | ||
|
||
function deploy_pull_request { | ||
REVIEW_ENVIRONMENT_DOMAIN='review.gnosisdev.com' | ||
|
||
# Pull request name with "pr" prefix | ||
PULL_REQUEST_NAME="pr$PR_NUMBER" | ||
|
||
# Only alphanumeric characters. Example safe-react-components -> safereactcomponents | ||
REVIEW_FEATURE_FOLDER="$REPO_NAME_ALPHANUMERIC/$PULL_REQUEST_NAME" | ||
|
||
aws s3 sync ${BUILD_DIR} s3://${REVIEW_BUCKET_NAME}/${REVIEW_FEATURE_FOLDER} --delete | ||
} | ||
|
||
function publish_pull_request_urls_in_github { | ||
REVIEW_FEATURE_URL="https://$PULL_REQUEST_NAME--$REPO_NAME_ALPHANUMERIC.$REVIEW_ENVIRONMENT_DOMAIN" | ||
|
||
# Using the Issues api instead of the PR api | ||
# Done so because every PR is an issue, and the issues api allows to post general comments, | ||
# while the PR api requires that comments are made to specific files and specific commits | ||
GITHUB_PR_COMMENTS=https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments | ||
curl -H "Authorization: token ${GITHUB_API_TOKEN}" --request POST ${GITHUB_PR_COMMENTS} --data '{"body":"Travis automatic deployment:\r\n '${REVIEW_FEATURE_URL}' \r\n"}' | ||
} | ||
|
||
# Only: | ||
# - Pull requests | ||
# - Security env variables are available. PR from forks don't have them. | ||
if [ -n "$AWS_ACCESS_KEY_ID" ] | ||
then | ||
deploy_pull_request | ||
# publish_pull_request_urls_in_github | ||
fi |
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,18 @@ | ||
#!/bin/bash | ||
|
||
set -ev | ||
|
||
# Only: | ||
# - Tagged commits | ||
# - Security env variables are available. | ||
if [ -n "$VERSION_TAG" ] && [ -n "$PROD_DEPLOYMENT_HOOK_TOKEN" ] && [ -n "$PROD_DEPLOYMENT_HOOK_URL" ] | ||
then | ||
# Call Devops Releases Handler CI | ||
curl --silent --output /dev/null --write-out "%{http_code}" -X POST \ | ||
-F token="$PROD_DEPLOYMENT_HOOK_TOKEN" \ | ||
-F ref=master \ | ||
-F "variables[TRIGGER_RELEASE_COMMIT_TAG]=$VERSION_TAG" \ | ||
$PROD_DEPLOYMENT_HOOK_URL | ||
else | ||
echo "[ERROR] Production deployment could not be prepared" | ||
fi |
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
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
Oops, something went wrong.