-
Notifications
You must be signed in to change notification settings - Fork 4
76 lines (66 loc) · 2.38 KB
/
deploy-ibm-roks.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
# This workflow deploys StockTrder CR to OCP cluster in IBM Cloud
#
### Before you begin:
# - Have access to IBM Cloud and OCP cluster
name: Deploy to ROKS
on:
push:
branches:
- main
paths-ignore:
- '.github/**'
# Environment variables available to all jobs and steps in this workflow
env:
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
IBM_CLOUD_REGION: ${{ secrets.IBM_CLOUD_REGION }}
IBM_CLOUD_RESOURCE_GROUP: ${{ secrets.IBM_CLOUD_RESOURCE_GROUP }}
IKS_CLUSTER: ${{ secrets.IKS_CLUSTER }}
DEPLOYMENT_NAME: trader
CLUSTER_NAMESPACE: ${{ secrets.CLUSTER_NAMESPACE }}
jobs:
deploy-to-ocp:
name: Deploy to OpenShift cluster
runs-on: ubuntu-latest
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v2
# Download and Install IBM Cloud CLI
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f kubernetes-service
ibmcloud plugin install -f container-registry
# Authenticate with IBM Cloud CLI
- name: Authenticate with IBM Cloud CLI
run: |
ibmcloud login --apikey "${IBM_CLOUD_API_KEY}" -r "${IBM_CLOUD_REGION}"
ibmcloud cr region-set "${IBM_CLOUD_REGION}"
ibmcloud cr login
# Install oc
- name: Install oc
uses: redhat-actions/oc-installer@v1
with:
oc_version: '4.6'
# Deploy the Docker image to the IKS cluster
- name: Deploy to IKS
run: |
ibmcloud ks cluster ls
echo $IKS_CLUSTER
ibmcloud ks cluster config --cluster $IKS_CLUSTER
kubectl config current-context
oc login -u apikey -p $IBM_CLOUD_API_KEY
echo "Configuring cluster namespace"
if kubectl get namespace ${CLUSTER_NAMESPACE}; then
echo -e "Namespace ${CLUSTER_NAMESPACE} found."
else
kubectl create namespace ${CLUSTER_NAMESPACE}
echo -e "Namespace ${CLUSTER_NAMESPACE} created."
fi
oc project ${CLUSTER_NAMESPACE}
ls -la application
oc apply -f application/stocktrader-cr.yaml
# oc set image deployment/$DEPLOYMENT_NAME trader=${{needs.setup-build-publish-deploy.outputs.image-registry-path}} --record
# oc rollout status deployment/$DEPLOYMENT_NAME