-
Notifications
You must be signed in to change notification settings - Fork 6
127 lines (106 loc) · 3.74 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
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
120
121
122
123
124
125
126
name: Deploy
on:
push:
branches:
- alpha
# - beta
# - main
env:
PROJECT_ID: bcsol-a8522
jobs:
deployStaging:
runs-on: ubuntu-latest
environment: Staging
concurrency: Staging
outputs:
version: ${{ steps.version.outputs.version }}
steps:
# setup
- uses: actions/checkout@v3
- name: Use Node.js 18.x (LTS)
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: npm
- run: npm ci
# determine version
- id: semantic-version
run: npm run release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# default to the latest tag version if no new release
- id: version
run: |
if [[ ${{ steps.semantic-version.outputs.new-release-published }} = 'true' ]]; then
echo "New version: ${{ steps.semantic-version.outputs.new-release-version }}"
echo 'semver=${{ steps.semantic-version.outputs.new-release-version }}' >> $GITHUB_OUTPUT
echo 'version=${{ steps.semantic-version.outputs.new-release-version }} (Build ${{ github.run_number }}-${{ github.run_attempt }})' >> $GITHUB_OUTPUT
else
LATEST_TAG=$(git describe --abbrev=0 --tags | tr -d v)
echo "Existing version: ${LATEST_TAG}"
echo "semver=${LATEST_TAG}" >> $GITHUB_OUTPUT
echo "version=${LATEST_TAG} (Build ${{ github.run_number }}-${{ github.run_attempt }})" >> $GITHUB_OUTPUT
fi
# test
# TODO
# - run: npm test
# - run: npm run lint
# build
- run: npm run build
env:
# GENERATE_SOURCEMAP: false
VITE_SEMVER: ${{ steps.version.outputs.semver }}
VITE_BUILD: ${{ github.run_number }}-${{ github.run_attempt }}
VITE_BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
# release
- run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# deploy
- id: deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
projectId: "${{ env.PROJECT_ID }}"
expires: 30d
channelId: staging
# notify
- uses: ./.github/actions/slack/
if: always()
with:
success: ${{ steps.version.outcome == 'success' && steps.deploy.outcome == 'success' }}
bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
environment: Staging
version: ${{ steps.version.outputs.version }}
app_url: ${{ steps.deploy.outputs.details_url }}
deployProd:
runs-on: ubuntu-latest
environment: Prod
concurrency: Prod
needs:
- deployStaging
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x (LTS)
uses: actions/setup-node@v3
with:
node-version: 18.x
# setup firebase CLI
- run: npm install -g firebase-tools
# promote from staging to production
- id: promote
run: |
echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > ./sa.json
export GOOGLE_APPLICATION_CREDENTIALS="${PWD}/sa.json"
firebase hosting:clone ${PROJECT_ID}:staging ${PROJECT_ID}:live
# notify
- uses: ./.github/actions/slack/
if: always()
with:
success: ${{ steps.promote.outcome == 'success' }}
bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
environment: Prod
version: ${{ needs.deployStaging.outputs.version }}
app_url: https://bettercallsol.dev