-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (107 loc) · 5.81 KB
/
deployment.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Build and Deploy to Netlify
on:
release:
types: [published]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
environment:
name: Production
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Read old BUILD_VERSION from config.json
run: |
OLD_VERSION=$(jq -r '.BUILD_VERSION' src/config/config.json)
echo "Github ref: $GITHUB_REF"
echo "Old BUILD_VERSION: $OLD_VERSION"
- name: Set Prod/Canary Environment Variables 🚀
if: startsWith(github.ref, 'refs/tags/main') || startsWith(github.ref, 'refs/tags/master') || startsWith(github.ref, 'refs/tags/prod') || startsWith(github.ref, 'refs/tags/canary')
run: |
echo "Setting prod branch secrets..."
echo "REACT_APP_TINY_MCE_KEY=${{ secrets.REACT_APP_TINY_MCE_KEY }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_API_KEY=${{ secrets.REACT_APP_FIREBASE_API_KEY_FOR_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_DATABASE_URL=${{ secrets.REACT_APP_FIREBASE_DATABASE_URL_FOR_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_STORAGE_BUCKET=${{ secrets.REACT_APP_FIREBASE_STORAGE_BUCKET }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.REACT_APP_FIREBASE_MESSAGING_SENDER_ID_FOR_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_APP_ID=${{ secrets.REACT_APP_FIREBASE_APP_ID_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_MEASUREMENT_ID=${{ secrets.REACT_APP_FIREBASE_MEASUREMENT_ID_FOR_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_PROJECT_ID=${{ secrets.REACT_APP_FIREBASE_PROJECT_ID_FOR_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_AUTH_DOMAIN=${{ secrets.REACT_APP_FIREBASE_AUTH_DOMAIN_FOR_PROD }}" >> $GITHUB_ENV
- name: Set Dev Environment Variables 🚀
if: startsWith(github.ref, 'refs/tags/dev')
run: |
echo "Setting dev branch secrets..."
echo "REACT_APP_TINY_MCE_KEY_FOR_DEV=${{ secrets.REACT_APP_TINY_MCE_KEY_FOR_DEV }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_API_KEY=${{ secrets.REACT_APP_FIREBASE_API_KEY }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_DATABASE_URL=${{ secrets.REACT_APP_FIREBASE_DATABASE_URL }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_STORAGE_BUCKET=${{ secrets.REACT_APP_FIREBASE_STORAGE_BUCKET }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.REACT_APP_FIREBASE_MESSAGING_SENDER_ID }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_APP_ID=${{ secrets.REACT_APP_FIREBASE_APP_ID }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_MEASUREMENT_ID=${{ secrets.REACT_APP_FIREBASE_MEASUREMENT_ID }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_PROJECT_ID=${{ secrets.REACT_APP_FIREBASE_PROJECT_ID }}" >> $GITHUB_ENV
echo "REACT_APP_FIREBASE_AUTH_DOMAIN=${{ secrets.REACT_APP_FIREBASE_AUTH_DOMAIN }}" >> $GITHUB_ENV
- name: Install dependencies
run: |
npm i --legacy-peer-deps
- name: Build App For Dev 🏗
if: startsWith(github.ref, 'refs/tags/dev')
run: |
npm run build:dev
- name: Build App For Canary 🏗
if: startsWith(github.ref, 'refs/tags/canary')
run: |
npm run build:canary
- name: Build App For Production 🏗
if: startsWith(github.ref, 'refs/tags/main') || startsWith(github.ref, 'refs/tags/main') || startsWith(github.ref, 'refs/tags/prod')
run: |
npm run build:prod
- name: Deploying to Prod 🚀
if: startsWith(github.ref, 'refs/tags/main') || startsWith(github.ref, 'refs/tags/main') || startsWith(github.ref, 'refs/tags/prod')
uses: data-intuitive/netlify-deploy-site@v1
with:
auth: ${{ secrets.NETLIFY_AUTH_TOKEN }}
dir: "build"
site: ${{ secrets.NETLIFY_PROD_SITE_ID }}
prod: true
message: "Deploying ${{ github.ref }}"
- name: Deploying to Canary 🚀
if: startsWith(github.ref, 'refs/tags/canary')
uses: data-intuitive/netlify-deploy-site@v1
with:
auth: ${{ secrets.NETLIFY_AUTH_TOKEN }}
dir: "build"
site: ${{ secrets.NETLIFY_CANARY_SITE_ID }}
prod: true
message: "Deploying ${{ github.ref }}"
- name: Deploying to Dev 🚀
if: startsWith(github.ref, 'refs/tags/dev') || startsWith(github.ref, 'refs/tags/setup-better-ci-cd')
uses: data-intuitive/netlify-deploy-site@v1
with:
auth: ${{ secrets.NETLIFY_AUTH_TOKEN }}
dir: "build"
site: ${{ secrets.NETLIFY_DEV_SITE_ID }}
prod: true
message: "Deploying ${{ github.ref }}"
- name: Report status to Slack
if: always()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
BRANCH_NAME=$(echo $GITHUB_REF | awk -F'/' '{print $3}')
BUILD_VERSION=$(jq -r '.BUILD_VERSION' < src/config/config.json)
MESSAGE="Workflow in $BRANCH_NAME with build version : $BUILD_VERSION has completed with status: *${{ job.status }}*"
STATUS_EMOJI=":white_check_mark:" # Use appropriate emoji for success status
if [[ "${{ job.status }}" != "success" ]]; then
STATUS_EMOJI=":x:" # Use appropriate emoji for failure status
fi
MESSAGE="Campaign Portal deployment workflow in $BRANCH_NAME with build number $BUILD_VERSION has completed with status: $STATUS_EMOJI ${{ job.status }}"
PAYLOAD="{\"text\": \"$MESSAGE\"}"
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL