-
Notifications
You must be signed in to change notification settings - Fork 39
80 lines (74 loc) · 3 KB
/
core-api.build.deploy.dev.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
name: CORE API - Build & Deploy To DEV
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- migrations/**
- services/core-api/**
- .github/workflows/core-api.build.deploy.dev.yaml
env:
INITIAL_TAG: latest
TAG: dev
NAME: backend
MIG: flyway
CONTEXT: services/core-api/
MIG_CONTEXT: migrations/
jobs:
build-backend:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login
run: |
docker login -u ${{ secrets.CLUSTER_REGISTRY_USER }} -p ${{ secrets.BUILD_TOKEN }} ${{ secrets.CLUSTER_REGISTRY }}
- name: Build n Tag
run: |
docker build -t ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ env.CONTEXT }} -f ${{ env.CONTEXT }}Dockerfile.ci
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.NAME }}:${{ env.INITIAL_TAG }}
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.NAME }}:${{ env.TAG }}
- name: Push
run: |
docker push --all-tags ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.NAME }}
build-flyway:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login
run: |
docker login -u ${{ secrets.CLUSTER_REGISTRY_USER }} -p ${{ secrets.BUILD_TOKEN }} ${{ secrets.CLUSTER_REGISTRY }}
- name: Build n Tag
run: |
docker build -t ${{ env.MIG }}:${{ env.INITIAL_TAG }} ${{ env.MIG_CONTEXT }} -f ${{ env.MIG_CONTEXT }}Dockerfile.flyway.ci
docker tag ${{ env.MIG }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.MIG }}:${{ env.INITIAL_TAG }}
docker tag ${{ env.MIG }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.MIG }}:${{ env.TAG }}
- name: Push
run: |
docker push --all-tags ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.MIG }}
trigger-gitops:
runs-on: ubuntu-20.04
timeout-minutes: 15
needs: [build-backend, build-flyway]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Git Ops Push
run: ./gitops/commit.sh core-api dev dev ${{ github.actor }} ${{ secrets.GH_TOKEN }}
- name: Install oc
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.7"
- name: oc login
run: oc login --token=${{ secrets.BUILD_TOKEN }} --server=${{ secrets.CLUSTER_API }}
- name: Notification
run: ./gitops/watch-deployment.sh core-api dev ${{ github.sha }} ${{ secrets.DISCORD_DEPLOYMENT_WEBHOOK }}
run-if-failed:
runs-on: ubuntu-20.04
needs: [trigger-gitops]
if: always() && (needs.trigger-gitops.result == 'failure')
steps:
- name: Notification
run: ./gitops/watch-deployment.sh core-api dev ${{ github.sha }} ${{ secrets.DISCORD_DEPLOYMENT_WEBHOOK }} 1