Skip to content

chore: branch named PR deployment #889

chore: branch named PR deployment

chore: branch named PR deployment #889

Workflow file for this run

name: Deploy to dev/staging
on:
pull_request:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions: write-all
name: Deploy to dev/staging
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.8.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: ./.github/workflows/yarn
- uses: ./.github/workflows/build
with:
secrets: ${{ toJSON(secrets) }}
is-production: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
# Extract branch name
- name: Extract branch name
if: github.event.number && startsWith(github.head_ref, 'epic-')
shell: bash
## Allow only alphanumeric characters and convert to lower case,
run: echo "branch=$(echo $GITHUB_HEAD_REF | sed 's/[^a-z0-9]/_/ig' | sed 's/[A-Z]/\L&/g')" >> $GITHUB_OUTPUT
id: extract_branch
# Deploy to S3
- name: Deploy epic PR branch
if: github.event.number && startsWith(github.head_ref, 'epic-')
env:
BUCKET: s3://${{ secrets.AWS_REVIEW_BUCKET_NAME }}/homepage/${{ steps.extract_branch.outputs.branch }}
run: bash ./scripts/github/s3_upload.sh
# Comment if epic branch PR
- name: Post an epic deployment link in the PR
if: always() && github.event.number && startsWith(github.head_ref, 'epic-')
uses: mshick/add-pr-comment@v2
with:
message-id: praul
message: |
## Branch preview
✅ Deployed successfully in branch deployment:
https://${{ steps.extract_branch.outputs.branch }}--homepage.review.5afe.dev
message-failure: |
## Branch preview
❌ Deploy failed!
# Deploy the main branch to 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
# Deploy all other branches to dev
- name: Deploy to the dev S3
if: github.event.number && !startsWith(github.head_ref, 'epic-')
env:
BUCKET: s3://${{ secrets.AWS_DEVELOPMENT_BUCKET_NAME }}
run: bash ./scripts/github/s3_upload.sh
- name: Post a deployment link in the PR
if: always() && github.event.number && !startsWith(github.head_ref, 'epic-')
uses: mshick/add-pr-comment@v2
with:
message-id: praul
message: |
## Branch preview
✅ Deployed to dev:
https://safe-web-landing.dev.5afe.dev
message-failure: |
## Branch preview
❌ Deploy failed!