forked from mckaywrigley/chatbot-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (115 loc) · 3.94 KB
/
ci-workable.yaml
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
name: Chatbot-ui Workable CI
on:
push:
branches:
- main-workable
pull_request:
types:
- opened
branches:
- main-workable
workflow_dispatch:
inputs:
tag:
description: "Set the image tag manually (will be created dynamically if not set)"
default: ""
required: false
manual_build_branch:
description: "The branch the image should be built from"
type: string
default: "main"
required: true
push_to_stg:
description: "Build and push image to staging GCR"
type: boolean
default: false
required: true
push_to_prd:
description: "Build and push image to production GCR"
type: boolean
default: false
required: true
jobs:
set-ref:
if: github.repository == 'Workable/chatbot-ui'
name: retrieve the actual build branch
runs-on: ubuntu-latest
outputs:
ref-for-name: ${{ steps.set-branch.outputs.ref-for-name }}
ref-for-checkout: ${{ steps.set-branch.outputs.ref-for-checkout }}
steps:
- name: set the build branch
id: set-branch
shell: bash
run: |
if [[ "${{ inputs.manual_build_branch }}" == "" ]]; then
ACTUAL_BRANCH=${{ github.ref_name }}
else
ACTUAL_BRANCH=${{ inputs.manual_build_branch }}
fi
echo "ref-for-name=${ACTUAL_BRANCH#workable_feature/*}" >> $GITHUB_OUTPUT
echo "ref-for-checkout=$ACTUAL_BRANCH" >> $GITHUB_OUTPUT
set-tag:
if: github.repository == 'Workable/chatbot-ui'
name: set the image tag
needs:
- set-ref
uses: Workable/chatbot-ui/.github/workflows/common_image_tagging_workflow.yaml@main-workable
with:
push_to_prd: ${{ inputs.push_to_prd == true }}
tag: ${{ inputs.tag }}
ref: ${{ needs.set-ref.outputs.ref-for-name }}
build-and-push-docker-image:
name: Build and push docker image
if: github.repository == 'Workable/chatbot-ui'
needs:
- set-ref
- set-tag
uses: Workable/chatbot-ui/.github/workflows/common_build_and_push_to_gcr.yaml@main-workable
with:
environment: Workable
dockerfile: Dockerfile.k8s
build_branch: ${{ needs.set-ref.outputs.ref-for-checkout }}
stg_image_build: ${{ inputs.push_to_stg == true || github.event_name == 'push' }}
prd_image_build: ${{ inputs.push_to_prd == true }}
image_name: chatbot-ui
image_tag: ${{ needs.set-tag.outputs.tag }}
no_cache: false
secrets:
SRE_GCR_SA: ${{ secrets.SRE_GCR_SA }}
STAGING_GCR_SA: ${{ secrets.STAGING_GCR_SA }}
PRODUCTION_GCR_SA: ${{ secrets.PRODUCTION_GCR_SA }}
send-slack-success:
name: Send Slack success message
if: success() && github.repository == 'Workable/chatbot-ui'
needs:
- set-tag
- build-and-push-docker-image
uses: Workable/chatbot-ui/.github/workflows/common_image_slack_notification.yaml@main-workable
with:
environment: Workable
image_name: chatbot-ui
image_tag: ${{ needs.set-tag.outputs.tag }}
slack_channel: sre_bots
stg_image_build: ${{ inputs.push_to_stg == true || github.event_name == 'push' }}
prd_image_build: ${{ inputs.push_to_prd == true }}
success: true
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
send-slack-failure:
name: Send Slack failure message
if: failure() && github.repository == 'Workable/chatbot-ui'
needs:
- set-tag
- build-and-push-docker-image
uses: Workable/chatbot-ui/.github/workflows/common_image_slack_notification.yaml@main-workable
with:
environment: Workable
image_name: chatbot-ui
image_tag: ${{ needs.set-tag.outputs.tag }}
slack_channel: sre_bots
stg_image_build: ${{ inputs.push_to_stg == true || github.event_name == 'push' }}
prd_image_build: ${{ inputs.push_to_prd == true }}
success: false
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}