-
Notifications
You must be signed in to change notification settings - Fork 13
132 lines (114 loc) · 3.77 KB
/
openshift.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
127
128
129
130
131
132
name: Build, push and deploy site
on:
push:
tags:
- '*'
branches:
- main
workflow_dispatch:
env:
OHIO_SITE_IMAGE: quay.io/operator-framework/operatorhubio
OHIO_REGISTRY_IMAGE: quay.io/operator-framework/upstream-community-operators
SOURCE_BRANCH: ${{ github.ref }}
jobs:
build:
name: Build site image
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16]
steps:
- name: Setup environment using Docker
run: |
if [[ $SOURCE_BRANCH == *"refs/tags"* ]]; then
docker run -d -p 50051:50051 --name registry $OHIO_REGISTRY_IMAGE:latest
else
docker run -d -p 50051:50051 --name registry $OHIO_REGISTRY_IMAGE:dev
fi
docker ps
- 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: Build server app using Nodejs
run: |
docker ps
cd server
npm install
npm run build-only
rm -rd node_modules
- name: Build site image
run: |
export OHIO_SITE_TAG=$(bash -c '
if [[ $SOURCE_BRANCH == *"refs/tags"* ]]; then
echo v4;
else
echo $SOURCE_BRANCH | cut -d "/" -f 3;
fi
')
docker build -t "$OHIO_SITE_IMAGE:$OHIO_SITE_TAG" -f travis.Dockerfile .
- name: Push new site image
if: ${{ contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/main' }}
run: |
export OHIO_SITE_TAG=$(bash -c '
if [[ $SOURCE_BRANCH == *"refs/tags"* ]]; then
echo v4;
else
echo $SOURCE_BRANCH | cut -d "/" -f 3;
fi
')
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin $DOCKER_REGISTRY
docker push "$OHIO_SITE_IMAGE:$OHIO_SITE_TAG"
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
deploy:
name: Deploy site
needs: build
runs-on: ubuntu-latest
env:
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }}
OPENSHIFT_TOKEN_DEV: ${{ secrets.OPENSHIFT_TOKEN_DEV }}
OPENSHIFT_TOKEN_PREPROD: ${{ secrets.OPENSHIFT_TOKEN_PREPROD }}
OPENSHIFT_TOKEN_PROD: ${{ secrets.OPENSHIFT_TOKEN_PROD }}
AKAMAI_SECRETS: ${{ secrets.AKAMAI_SECRETS }}
AKAMAI_APPCODES: ${{ secrets.AKAMAI_APPCODES }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy to DEV
if: ${{ github.ref == 'refs/heads/main' }}
run: |
./deploy.sh dev
- name: Deploy to PREPROD
if: ${{ contains(github.ref, 'refs/tags') }}
run: |
./deploy.sh preprod
- name: Deploy to PROD
if: ${{ contains(github.ref, 'refs/tags') }}
run: |
./deploy.sh prod
- name: Invalidate Akamai cache
if: ${{ contains(github.ref, 'refs/tags') }}
run: |
./invalidate.sh
slack-notification:
name: "Slack notification"
needs: [ build, deploy ]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Report Status
uses: ravsamhq/notify-slack-action@master
with:
notification_title: 'Operatorhub.io deploy failed: ${{ needs.pr-check.outputs.opp_pr_title }}'
footer: 'monitoring'
# status: ${{ needs.pr-check.result }}
status: 'failure'
notify_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
continue-on-error: true