Merge pull request #5 from bnb-chain/feat-pancake-address #21
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
name: Deploy to dev/staging | |
on: | |
pull_request: | |
push: | |
branches: | |
- dev | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: 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@v3 | |
- uses: ./.github/workflows/yarn | |
- uses: ./.github/workflows/build | |
with: | |
secrets: ${{ toJSON(secrets) }} | |
- 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 }} | |
# Staging | |
- name: Deploy to the staging S3 | |
if: 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: 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! | |
https://${{ steps.extract_branch.outputs.branch }}--walletweb.review-wallet-web.5afe.dev | |
message-failure: | | |
## Branch preview | |
❌ Deploy failed! |