-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
242 additions
and
43 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,62 @@ | ||
name: 'Build' | ||
|
||
description: 'Build the app' | ||
|
||
inputs: | ||
secrets: | ||
required: true | ||
|
||
prod: # id of input | ||
description: 'Production build flag' | ||
required: false | ||
|
||
e2e_mnemonic: | ||
description: 'Mnemonic for the E2E tests' | ||
required: false | ||
|
||
runs: | ||
using: 'composite' | ||
|
||
steps: | ||
- name: Set environment variables | ||
shell: bash | ||
run: | | ||
if [ "${{ inputs.prod }}" = "true" ]; then | ||
echo "NEXT_PUBLIC_INFURA_TOKEN=${{ fromJSON(inputs.secrets).NEXT_PUBLIC_INFURA_TOKEN }}" >> $GITHUB_ENV | ||
echo "NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN=${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN }}" >> $GITHUB_ENV | ||
else | ||
echo "NEXT_PUBLIC_INFURA_TOKEN=${{ fromJSON(inputs.secrets).NEXT_PUBLIC_INFURA_TOKEN_DEVSTAGING }}" >> $GITHUB_ENV | ||
echo "NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN=${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN_DEVSTAGING }}" >> $GITHUB_ENV | ||
fi | ||
- name: Build | ||
shell: bash | ||
run: yarn build | ||
env: | ||
NEXT_PUBLIC_IS_PRODUCTION: ${{ inputs.prod }} | ||
NEXT_PUBLIC_CYPRESS_MNEMONIC: ${{ inputs.e2e_mnemonic }} | ||
NEXT_PUBLIC_GATEWAY_URL_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GATEWAY_URL_PRODUCTION }} | ||
NEXT_PUBLIC_GATEWAY_URL_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GATEWAY_URL_STAGING }} | ||
NEXT_PUBLIC_SAFE_VERSION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_VERSION }} | ||
NEXT_PUBLIC_BEAMER_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_BEAMER_ID }} | ||
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_DEVELOPMENT_AUTH: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GOOGLE_TAG_MANAGER_DEVELOPMENT_AUTH }} | ||
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID }} | ||
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LATEST_AUTH: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LATEST_AUTH }} | ||
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LIVE_AUTH: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LIVE_AUTH }} | ||
NEXT_PUBLIC_SENTRY_DSN: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SENTRY_DSN }} | ||
NEXT_PUBLIC_TENDERLY_ORG_NAME: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_TENDERLY_ORG_NAME }} | ||
NEXT_PUBLIC_TENDERLY_PROJECT_NAME: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_TENDERLY_PROJECT_NAME }} | ||
NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL }} | ||
NEXT_PUBLIC_WC_PROJECT_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_WC_PROJECT_ID }} | ||
NEXT_PUBLIC_SAFE_RELAY_SERVICE_URL_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_GELATO_RELAY_SERVICE_URL_PRODUCTION }} | ||
NEXT_PUBLIC_SAFE_RELAY_SERVICE_URL_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_GELATO_RELAY_SERVICE_URL_STAGING }} | ||
NEXT_PUBLIC_IS_OFFICIAL_HOST: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_IS_OFFICIAL_HOST }} | ||
NEXT_PUBLIC_BLOCKAID_CLIENT_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_BLOCKAID_CLIENT_ID }} | ||
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING }} | ||
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION }} | ||
NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION }} | ||
NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING }} | ||
NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION }} | ||
NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING }} | ||
NEXT_PUBLIC_SPINDL_SDK_KEY: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SPINDL_SDK_KEY }} | ||
NEXT_PUBLIC_ECOSYSTEM_ID_ADDRESS: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_ECOSYSTEM_ID_ADDRESS }} |
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 |
---|---|---|
@@ -1,22 +1,72 @@ | ||
name: "Cache Dependencies" | ||
description: "Caches node_modules and other directories" | ||
name: "Cache Yarn Dependencies" | ||
description: "Restore or save yarn dependencies" | ||
inputs: | ||
mode: | ||
description: "restore-yarn | save-yarn | restore-nc | safe-nc" | ||
required: true | ||
|
||
outputs: | ||
cache-primary-key: | ||
value: ${{ steps.restore.outputs.cache-primary-key }} | ||
description: "The primary key used for the cache" | ||
cache-nc-key: | ||
value: ${{ steps.restore-nc.outputs.cache-primary-key }} | ||
description: "The primary key used for the cache" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Yarn cache | ||
uses: actions/cache@v4 | ||
- name: Restore Yarn Cache | ||
if: ${{ inputs.mode == 'restore-yarn' }} | ||
id: restore | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
**/node_modules | ||
${{ github.workspace }}/.yarn/install-state.gz | ||
${{ github.workspace }}/src/types | ||
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json','**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-web-core-modules- | ||
- name: Set composite outputs yarn | ||
if: ${{ inputs.mode == 'restore-yarn' }} | ||
shell: bash | ||
run: echo "cache-primary-key=${{ steps.restore.outputs.cache-primary-key }}" >> $GITHUB_OUTPUT | ||
|
||
- name: Save Yarn Cache | ||
if: ${{ inputs.mode == 'save-yarn' }} | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: | | ||
**/node_modules | ||
${{ github.workspace }}/.yarn/install-state.gz | ||
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json', '**/yarn.lock') }} | ||
${{ github.workspace }}/src/types | ||
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json','**/yarn.lock') }} | ||
|
||
- name: Nextjs/Cypress cache | ||
uses: actions/cache@v4 | ||
- name: Restore Nextjs/Cypress Cache | ||
if: ${{ inputs.mode == 'restore-nc' }} | ||
id: restore-nc | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
${{ github.workspace }}/.next/cache | ||
/home/runner/.cache/Cypress | ||
key: ${{ runner.os }}-nextjs-cypress-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | ||
restore-keys: | | ||
${{ runner.os }}-nextjs-cypress- | ||
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- | ||
- name: Set composite outputs nc | ||
if: ${{ inputs.mode == 'restore-nc' }} | ||
shell: bash | ||
run: echo "cache-primary-key=${{ steps.restore-nc.outputs.cache-primary-key }}" >> $GITHUB_OUTPUT | ||
|
||
|
||
- name: Save Nextjs/Cypress Cache | ||
if: ${{ inputs.mode == 'save-nc' }} | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: | | ||
${{ github.workspace }}/.next/cache | ||
/home/runner/.cache/Cypress | ||
key: ${{ steps.restore-nc.outputs.cache-primary-key }} |
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,8 @@ | ||
name: "Enable corepack" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Enable Corepack" | ||
shell: bash | ||
run: corepack enable |
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 |
---|---|---|
|
@@ -20,37 +20,24 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Enable Corepack | ||
shell: bash | ||
run: corepack enable | ||
- uses: ./.github/actions/corepack | ||
|
||
- name: Restore Yarn Cache & Types | ||
id: restore-yarn-types | ||
uses: actions/cache/restore@v4 | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
path: | | ||
**/node_modules | ||
${{ github.workspace }}/.yarn/install-state.gz | ||
${{ github.workspace }}/src/types | ||
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json', '**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-web-core-modules- | ||
mode: restore-yarn | ||
|
||
- name: Yarn install & after-install generate types | ||
if: steps.restore-yarn-types.outputs.cache-hit != 'true' | ||
run: | | ||
yarn install --immutable | ||
yarn after-install | ||
- name: Save Yarn Cache | ||
- name: Save Yarn Cache & Types | ||
if: steps.restore-yarn-types.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
path: | | ||
**/node_modules | ||
${{ github.workspace }}/.yarn/install-state.gz | ||
${{ github.workspace }}/src/types | ||
key: ${{ steps.restore-yarn-types.outputs.cache-primary-key }} | ||
mode: save | ||
|
||
eslint: | ||
needs: build | ||
|
@@ -63,13 +50,10 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Yarn Cache | ||
uses: actions/cache/restore@v4 | ||
- name: Restore Yarn Cache & Types | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
path: | | ||
**/node_modules | ||
${{ github.workspace }}/.yarn/install-state.gz | ||
key: ${{ needs.build.outputs.yarn-types-cache-key }} | ||
mode: restore-yarn | ||
|
||
- uses: CatChen/[email protected] | ||
with: | ||
|
@@ -91,18 +75,12 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Enable Corepack | ||
shell: bash | ||
run: corepack enable | ||
- uses: ./.github/actions/corepack | ||
|
||
- name: Restore Yarn Cache | ||
uses: actions/cache/restore@v4 | ||
- name: Restore Yarn Cache & Types | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
path: | | ||
**/node_modules | ||
${{ github.workspace }}/.yarn/install-state.gz | ||
${{ github.workspace }}/src/types | ||
key: ${{ needs.build.outputs.yarn-types-cache-key }} | ||
mode: restore-yarn | ||
|
||
- name: Annotations and coverage report | ||
uses: ArtiomTr/[email protected] | ||
|
@@ -112,3 +90,104 @@ jobs: | |
package-manager: yarn | ||
test-script: yarn test:ci | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
id-token: write | ||
|
||
name: Deploy to dev/staging | ||
|
||
steps: | ||
# Post a PR comment before deploying | ||
- name: Post a comment while building | ||
if: github.event.number | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message-id: praul | ||
message: | | ||
## Branch preview | ||
⏳ Deploying a preview site... | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
repo-token-user-login: 'github-actions[bot]' | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Yarn Cache & Types | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
mode: restore-yarn | ||
|
||
- name: Restore Yarn Cache & Types | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
mode: restore-nc | ||
|
||
- uses: ./.github/actions/build | ||
with: | ||
secrets: ${{ toJSON(secrets) }} | ||
if: startsWith(github.ref, 'refs/heads/main') | ||
|
||
- name: Restore Yarn Cache & Types | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
mode: save-nc | ||
#- uses: ./.github/workflows/build-storybook | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
# Staging | ||
- name: Deploy to the staging S3 | ||
if: startsWith(github.ref, 'refs/heads/main') | ||
env: | ||
BUCKET: s3://${{ secrets.AWS_STAGING_BUCKET_NAME }}/current | ||
run: bash ./scripts/github/s3_upload.sh | ||
|
||
# Dev | ||
- name: Deploy to the dev S3 | ||
if: startsWith(github.ref, 'refs/heads/dev') | ||
env: | ||
BUCKET: s3://${{ secrets.AWS_DEVELOPMENT_BUCKET_NAME }} | ||
run: bash ./scripts/github/s3_upload.sh | ||
|
||
### PRs ### | ||
|
||
# Extract branch name | ||
- name: Extract branch name | ||
shell: bash | ||
## Cut off "refs/heads/", only allow alphanumeric characters and convert to lower case, | ||
## e.g. "refs/heads/features/hello-1.2.0" -> "features_hello_1_2_0" | ||
run: echo "branch=$(echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///' | sed 's/[^a-z0-9]/_/ig' | sed 's/[A-Z]/\L&/g')" >> $GITHUB_OUTPUT | ||
id: extract_branch | ||
|
||
# Deploy to S3 | ||
- name: Deploy PR branch | ||
if: github.event.number | ||
env: | ||
BUCKET: s3://${{ secrets.AWS_REVIEW_BUCKET_NAME }}/walletweb/${{ steps.extract_branch.outputs.branch }} | ||
run: bash ./scripts/github/s3_upload.sh | ||
|
||
# Comment | ||
- name: Post a deployment link in the PR | ||
if: always() && github.event.number | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message-id: praul | ||
message: | | ||
## Branch preview | ||
✅ Deploy successful! | ||
**Website:** | ||
https://${{ steps.extract_branch.outputs.branch }}--walletweb.review.5afe.dev/home?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6 | ||
**Storybook:** | ||
https://${{ steps.extract_branch.outputs.branch }}--walletweb.review.5afe.dev/storybook/ | ||
message-failure: | | ||
## Branch preview | ||
❌ Deploy failed! |