-
Notifications
You must be signed in to change notification settings - Fork 17
62 lines (50 loc) · 1.65 KB
/
api-cd.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
name: EPICTRACK API CD
on:
push:
branches:
- develop
paths:
- "epictrack-api/**"
workflow_dispatch:
inputs:
environment:
description: "Environment (dev/test/prod)"
required: true
default: "dev"
defaults:
run:
shell: bash
working-directory: ./epictrack-api
env:
APP_NAME: "epictrack-api"
TAG_NAME: "${{ github.event.inputs.environment || 'dev' }}" # If the environment type is manually selected, use the input value; otherwise, use 'dev' as default
jobs:
api-cd:
runs-on: ubuntu-20.04
if: github.repository == 'bcgov/EPIC.track'
environment:
name: "dev"
steps:
- uses: actions/checkout@v2
- name: Login Openshift
shell: bash
run: |
oc login --server=${{secrets.OPENSHIFT_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT_SA_TOKEN}}
- name: Login Docker
run: |
echo "${{ secrets.OPENSHIFT_SA_TOKEN }}" |
docker login ${{ secrets.OPENSHIFT_IMAGE_REGISTRY }} -u ${{ secrets.OPENSHIFT_SA_NAME}} --password-stdin
- name: Build image
run: |
docker build . --file Dockerfile --tag image
- name: Push image
run: |
IMAGE_ID=${{ secrets.OPENSHIFT_IMAGE_REGISTRY }}/"${{ secrets.OPENSHIFT_REPOSITORY}}-tools"/$APP_NAME
docker tag image $IMAGE_ID:latest
docker push $IMAGE_ID:latest
docker image tag $IMAGE_ID:latest $IMAGE_ID:$TAG_NAME
docker push $IMAGE_ID:$TAG_NAME
- name: Rollout
shell: bash
run: |
oc rollout status dc/${{ env.APP_NAME }} -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ env.TAG_NAME }} -w