-
-
Notifications
You must be signed in to change notification settings - Fork 2
76 lines (73 loc) · 2.48 KB
/
web-app-ci-cd.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
name: "Web App CI / CD"
on:
pull_request: {}
push:
branches: [main]
paths: [web-app/**]
workflow_dispatch:
inputs:
What-If:
description: "What-If: Set to 'false' if you want to deploy"
required: true
default: "true"
env:
working_directory: ./web-app
jobs:
build:
name: "Web App Build"
if: github.event_name == 'pull_request' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.What-If == 'true' )
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Build and test
uses: ./.github/workflows/composite/web-app-build-test
- name: git push lint fixes
run: |
git config user.name github-actions
git config user.email [email protected]
git diff-index --quiet HEAD || git commit -am "Autofix ESLint errors"
git push
- name: Prepare dist
env:
NODE_ENV: "production"
working-directory: ${{ env.working_directory }}
shell: bash
run: ./scripts/make_dist.sh
build-and-deploy:
name: "Web App Build & Deploy"
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.What-If == 'false' ))
runs-on: ubuntu-latest
environment:
name: "production"
url: ${{ steps.azure-webapps-deploy.outputs.webapp-url }}
concurrency: production-deploy
env:
slot_name: "Production"
app_name: "announcement-drafter"
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
# NOTE: set the fetch-depth to be sure you retrieve all commits to look for the semver commit message
fetch-depth: "0"
- name: Build and test
uses: ./.github/workflows/composite/web-app-build-test
- name: Prepare dist
env:
NODE_ENV: "production"
working-directory: ${{ env.working_directory }}
shell: bash
run: ./scripts/make_dist.sh
- name: "Deploy to Azure Web App"
id: azure-webapps-deploy
uses: azure/webapps-deploy@v2
env:
NODE_ENV: "production"
with:
app-name: ${{ env.app_name }}
slot-name: ${{ env.slot_name }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}
package: "${{ env.working_directory }}/dist"