This repository has been archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
113 lines (97 loc) · 3.17 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
name: Build, push and deploy site
on:
push:
tags:
- '*'
branches:
- master
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: [14]
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/master' }}
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/master' }}
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