Updates to 0bd92fe54e1be773e0bfc29c5ffb43000c954f14 #274
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |