-
-
Notifications
You must be signed in to change notification settings - Fork 30
117 lines (102 loc) · 5.3 KB
/
deployment.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
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
name: Deployment
on:
workflow_call:
inputs:
component:
description: The component to deploy (admin|functions|rules)
type: string
required: true
project:
description: The Firebase project to deploy to (social-income-staging|social-income-prod)
type: string
required: true
jobs:
deploy-admin:
name: Deploy admin on Firebase
runs-on: ubuntu-latest
if: inputs.component == 'admin'
env:
VITE_WEBSITE_BASE_URL: ${{ (inputs.project == 'social-income-prod' && 'https://socialincome.org') || 'https://staging.socialincome.org' }}
VITE_ADMIN_ALGOLIA_APPLICATION_ID: ${{ secrets.REACT_APP_ADMIN_ALGOLIA_APPLICATION_ID }}
VITE_ADMIN_ALGOLIA_SEARCH_KEY: ${{ secrets.REACT_APP_ADMIN_ALGOLIA_SEARCH_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize repository
uses: ./.github/workflows/actions/init
with:
project: ${{ inputs.project }}
firebaseServiceAccountJSON: ${{ (inputs.project == 'social-income-prod' && secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_PROD) || secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_STAGING }}
- name: Build admin
run: npm run admin:build
- name: Deploy preview on Firebase (social-income-staging)
if: ${{ inputs.project == 'social-income-staging' && github.ref != 'refs/heads/main' }}
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_STAGING }}"
projectId: social-income-staging
target: admin
- name: Deploy on Firebase (social-income-staging)
if: ${{ inputs.project == 'social-income-staging' && github.ref == 'refs/heads/main' }}
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_STAGING }}"
projectId: social-income-staging
target: admin
channelId: live
- name: Deploy on Firebase (social-income-prod)
if: inputs.project == 'social-income-prod'
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_PROD }}"
projectId: social-income-prod
target: admin
channelId: live
deploy-functions:
name: Deploy functions on Firebase
runs-on: ubuntu-latest
if: inputs.component == 'functions'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize repository
uses: ./.github/workflows/actions/init
with:
project: ${{ inputs.project }}
firebaseServiceAccountJSON: ${{ (inputs.project == 'social-income-prod' && secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_PROD) || secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_STAGING }}
- name: Add secrets to functions/.env file
working-directory: functions
run: |
echo EXCHANGE_RATES_API=${{ secrets.EXCHANGE_RATES_API }} >> .env
echo POSTFINANCE_FTP_HOST=${{ vars.POSTFINANCE_FTP_HOST }} >> .env
echo POSTFINANCE_FTP_PORT=${{ vars.POSTFINANCE_FTP_PORT }} >> .env
echo POSTFINANCE_FTP_RSA_PRIVATE_KEY_BASE64=${{ secrets.POSTFINANCE_FTP_RSA_PRIVATE_KEY_BASE64 }} >> .env
echo POSTFINANCE_FTP_USER=${{ vars.POSTFINANCE_FTP_USER }} >> .env
echo POSTFINANCE_PAYMENTS_FILES_BUCKET=${{ (inputs.project == 'social-income-prod' && vars.POSTFINANCE_PAYMENTS_FILES_BUCKET) || vars.POSTFINANCE_PAYMENTS_FILES_BUCKET_STAGING }} >> .env
echo SENDGRID_API_KEY=${{ secrets.SENDGRID_API_KEY }} >> .env
echo STRIPE_API_READ_KEY=${{ (inputs.project == 'social-income-prod' && secrets.STRIPE_API_READ_KEY) || secrets.STRIPE_API_READ_KEY_STAGING }} >> .env
echo STRIPE_WEBHOOK_SECRET=${{ (inputs.project == 'social-income-prod' && secrets.STRIPE_WEBHOOK_SECRET) || secrets.STRIPE_WEBHOOK_SECRET_STAGING }} >> .env
- name: Build functions
run: npm run functions:build
- name: Deploy on Firebase (${{ inputs.project }})
run: GOOGLE_APPLICATION_CREDENTIALS=credentials.json firebase deploy --only functions --project ${{ inputs.project }}
deploy-rules:
name: Deploy Firestore and Storage rules on Firebase
runs-on: ubuntu-latest
if: inputs.component == 'rules'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize repository
uses: ./.github/workflows/actions/init
with:
installDependencies: "false"
project: ${{ inputs.project }}
firebaseServiceAccountJSON: ${{ (inputs.project == 'social-income-prod' && secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_PROD) || secrets.FIREBASE_SERVICE_ACCOUNT_SOCIAL_INCOME_STAGING }}
- name: Deploy on Firebase (${{ inputs.project }})
run: |
GOOGLE_APPLICATION_CREDENTIALS=credentials.json firebase deploy --only firestore:rules --project ${{ inputs.project }}
GOOGLE_APPLICATION_CREDENTIALS=credentials.json firebase deploy --only storage --project ${{ inputs.project }}