-
Notifications
You must be signed in to change notification settings - Fork 75
122 lines (112 loc) · 3.56 KB
/
deploy-master.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
name: Build and Deploy
on:
workflow_dispatch:
push:
branches: [master]
jobs:
cancel-running-jobs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
deploy:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/master'
strategy:
matrix:
include:
- name: website-diag
site-id: NETLIFY_SITEID_DIAG
- name: website-pathology
site-id: NETLIFY_SITEID_PATHOLOGY
- name: website-rse
site-id: NETLIFY_SITEID_RSE
- name: website-rtc
site-id: NETLIFY_SITEID_RTC
- name: website-ai-for-health
site-id: NETLIFY_SITEID_AIFORHEALTH
- name: website-cara-lab
site-id: NETLIFY_SITEID_CARALAB
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: 'pip'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
yarn config set prefix $(yarn cache dir)
echo $(yarn global bin) >> $GITHUB_PATH
yarn config set global-folder $(yarn cache dir)
- name: Cache Yarn
uses: actions/cache@v2
env:
cache-version: v1
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: ${{ runner.os }}-yarn-${{ env.cache-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.cache-version }}-
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Install Netlify
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn global add netlify-cli
- name: Build and Deploy
uses: ./.github/workflows/actions/build-and-deploy
with:
website-dir: ${{ matrix.name }}
website-api: ${{ secrets[matrix.site-id] }}
netlify_key: ${{ secrets.NETLIFY_DEV_AUTH }}
github_token: ${{ secrets.GH_BIB_TOKEN }}
notify:
needs: deploy
if: ${{ failure() && github.event_name != 'workflow_dispatch'}}
runs-on: ubuntu-20.04
steps:
- name: Send message to Teams channel
run: |
cat << EOF > message.json
{
"@type":"MessageCard",
"@context":"https://schema.org/extensions",
"summary":"Build failed!",
"themeColor":"E4340E",
"title":"$GITHUB_REPOSITORY deployment failed",
"sections":[
{
"facts":[
{
"name":"Branch:",
"value":"$GITHUB_REF_NAME"
},
{
"name":"Commit:",
"value":"$GITHUB_SHA"
}
]
}
],
"potentialAction":[
{
"@type":"OpenUri",
"name":"View on GitHub",
"targets":[
{
"os":"default",
"uri":"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
}
]
}
]
}
EOF
curl -X POST ${{ secrets.TEAMS_WEBHOOK_URL }} --header 'Content-Type: application/json' -f -S -d @message.json