Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add feature branch deployments #469

Merged
merged 2 commits into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Deploy to staging

on:
push:
branches:
- main
pull_request:

jobs:
deploy:
Expand All @@ -18,6 +16,18 @@ jobs:
with:
access_token: ${{ github.token }}

# 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: pnpm/action-setup@v2
Expand Down Expand Up @@ -46,3 +56,32 @@ jobs:
env:
BUCKET: s3://${{ secrets.AWS_STAGING_BUCKET_NAME }}/current
run: bash ./.github/scripts/s3_upload.sh

# Extract branch name
- name: Extract branch name
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 PR branch
if: github.event.number
env:
BUCKET: s3://${{ secrets.AWS_REVIEW_BUCKET_NAME }}/docs/${{ steps.extract_branch.outputs.branch }}
run: bash ./.github/scripts/s3_upload.sh

# Comment with the deployment link
- name: Post an epic deployment link in the PR
if: always() && github.event.number
uses: mshick/add-pr-comment@v2
with:
message-id: praul
message: |
## Branch preview
✅ Deployed successfully in branch deployment:

https://${{ steps.extract_branch.outputs.branch }}--docs.review.5afe.dev
message-failure: |
## Branch preview
❌ Deploy failed!
Loading