-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (108 loc) · 4.22 KB
/
deploy-openshift-es.yaml
File metadata and controls
123 lines (108 loc) · 4.22 KB
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
name: reusable Eventstore deploy to OpenShift Container Platform
on:
workflow_call:
inputs:
app_name:
required: true
type: string
namespace:
required: true
type: string
secrets:
OCP_TOKEN_DEV:
required: true
OCP_TOKEN_STAGE:
required: true
OCP_TOKEN_PROD:
required: true
SLACK_WEBHOOK_DEV:
required: true
SLACK_WEBHOOK_STAGE:
required: true
SLACK_WEBHOOK_PROD:
required: true
env:
BASE_NAME: ${{ inputs.app_name }}
jobs:
deploy:
runs-on: ubuntu-24.04
name: Deploy to OpenShift
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/stage' || github.ref == 'refs/heads/prod'
steps:
- name: Install oc
uses: redhat-actions/openshift-tools-installer@v1.10
with:
oc: '4.7'
- name: Set OpenShift context (dev)
uses: redhat-actions/oc-login@v1.1
with:
# TODO don't like this in public repo
openshift_server_url: https://api.dev01.squeegee.cloud:6443
openshift_token: ${{ secrets.OCP_TOKEN_DEV }}
namespace: ${{ inputs.namespace }}
if: github.ref == 'refs/heads/dev'
- name: Set OpenShift context (stage)
uses: redhat-actions/oc-login@v1.1
with:
openshift_server_url: https://api.stage01.squeegee.cloud:6443
openshift_token: ${{ secrets.OCP_TOKEN_STAGE }}
namespace: ${{ inputs.namespace }}
if: github.ref == 'refs/heads/stage'
- name: Set OpenShift context (prod)
uses: redhat-actions/oc-login@v1.1
with:
openshift_server_url: https://api.prod01.squeegee.cloud:6443
openshift_token: ${{ secrets.OCP_TOKEN_PROD }}
namespace: ${{ inputs.namespace }}
if: github.ref == 'refs/heads/prod'
- name: deploy
run: |
TAG=sha-$(echo $GITHUB_SHA | cut --characters=1-7)
CONTAINER_IMAGE=ghcr.io/$GITHUB_REPOSITORY:$TAG
TRIGGER_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
CHANGE_CAUSE="Commit: $TAG, Trigger: $TRIGGER_URL"
oc patch --type=merge $BASE_NAME $BASE_NAME --patch '{ "spec": { "image":"'"$CONTAINER_IMAGE"'" } }'
oc annotate statefulset.app/$BASE_NAME kubernetes.io/change-cause="$CHANGE_CAUSE"
oc rollout status statefulset.app/$BASE_NAME
- name: Slack success (dev)
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEV }}
SLACK_TITLE: '${{ inputs.app_name }} Deployment Success!'
SLACK_COLOR: '#228B22'
if: success() && github.ref == 'refs/heads/dev'
- name: Slack success (stage)
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_STAGE }}
SLACK_TITLE: '${{ inputs.app_name }} Deployment Success!'
SLACK_COLOR: '#228B22'
if: success() && github.ref == 'refs/heads/stage'
- name: Slack success (prod)
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_PROD }}
SLACK_TITLE: '${{ inputs.app_name }} Deployment Success!'
SLACK_COLOR: '#228B22'
if: success() && github.ref == 'refs/heads/prod'
- name: Slack failure (dev)
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEV }}
SLACK_TITLE: '${{ inputs.app_name }} Deployment Failure!'
SLACK_COLOR: '#E01E5A'
if: failure() && github.ref == 'refs/heads/dev'
- name: Slack failure (stage)
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_STAGE }}
SLACK_TITLE: '${{ inputs.app_name }} Deployment Failure!'
SLACK_COLOR: '#E01E5A'
if: failure() && github.ref == 'refs/heads/stage'
- name: Slack failure (prod)
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_PROD }}
SLACK_TITLE: '${{ inputs.app_name }} Deployment Failure!'
SLACK_COLOR: '#E01E5A'
if: failure() && github.ref == 'refs/heads/prod'