-
Notifications
You must be signed in to change notification settings - Fork 15
77 lines (63 loc) · 2.3 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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@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 }}
# Extract branch name
- name: Extract branch name
if: github.event.number && startsWith(github.head_ref, 'epic-')
shell: bash
## Remove the prefix "refs/heads/", allow only alphanumeric characters and convert to lower case,
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
echo "GitHub Ref: $GITHUB_REF"
echo "GitHub Head Ref: $GITHUB_HEAD_REF"
echo "GitHub event number: $GITHUB_EVENT_NUMBER"
# # 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.ref != 'refs/heads/main'
# env:
# BUCKET: s3://${{ secrets.AWS_DEVELOPMENT_BUCKET_NAME }}
# 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
✅ Deployed to dev:
https://safe-web-landing.dev.5afe.dev
message-failure: |
## Branch preview
❌ Deploy failed!