Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Github Actions Pipeline for openshift deployment

Use Case

Write a github action job which would build an image and then publish to ghcr. Upon Successful publishing, trigger a openshift deployment


name: OpenShift Deployment

on:
push:
branches:
– main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
  uses: actions/checkout@v2

- name: Build Docker image
  run: docker build -t my-image:latest .

- name: Log in to Docker registry
  run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push Docker image to GHCR
  run: docker push ghcr.io/${{ github.repository_owner }}/my-image:latest

- name: Set up OpenShift CLI
  uses: redhat-actions/oc-login@v1
  with:
    openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL }}
    openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}

- name: Trigger OpenShift deployment
  run: |
    oc project my-project
    oc rollout latest deployment/my-deploymentCode language: JavaScript (javascript)

To use this workflow, you need to set up the following secrets in your GitHub repository:

  • OPENSHIFT_SERVER_URL: The URL of your OpenShift server.
  • OPENSHIFT_TOKEN: An authentication token to access your OpenShift cluster.

Make sure to replace my-image, my-project, and my-deployment with your own image, project, and deployment names.

This workflow listens for pushes to the main branch. When a push event occurs, it checks out the repository, builds a Docker image, logs in to GHCR using the provided GITHUB_TOKEN, pushes the image to GHCR, sets up the OpenShift CLI using the provided secrets, and finally triggers an OpenShift deployment by rolling out the latest changes to the specified deployment.

Ensure that your GitHub Actions runner has the necessary access permissions to push the Docker image to GHCR and trigger the OpenShift deployment.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Best DevOps Tools in 2024

hereโ€™s a clear, structured breakdown of the Best DevOps Tools (grouped by categories), so you can use it for learning, training, or posts. ๐Ÿš€ Best DevOps Tools…

Read More

OpenShift Tutorial โ€“ Deploy and Access Your First Applications using OpenShift Local

How to install oc? OpenShift: How to Install OpenShift CLI oc How to login? Login to the Openshift using Web Console and CLI using oc Copy the admin…

Read More

OpenShift Lab 14: Setting Up and Using OpenShift Serverless Functions on OpenShift Local

Lab Objective In this lab, you will install and use OpenShift Serverless Functions on OpenShift Local. You will create a simple Node.js serverless function, deploy it to…

Read More

OpenShift Lab 13: Deploy a Java Spring Boot Application with MySQL Using the OpenShift Web Console

Lab Objective In this lab, you will deploy a Java Spring Boot application on OpenShift using the OpenShift web console. You will deploy two components: The Java…

Read More

OpenShift Lab 12: Deploy an Application from an Existing Container Image Using the OpenShift Web Console

Lab Objective In this lab, you will deploy an application on OpenShift from an existing container image. This lab is different from building an application from source…

Read More

OpenShift: How to Install OpenShift CLIย oc

Option – 1 – REDHAT Websites URL – https://access.redhat.com/downloads/content/290/ver=4.18/rhel—9/4.18.11/x86_64/product-software Option – 2 – OKD Websites The OKD (Origin Community Distribution of Kubernetes for OpenShift) is the open-source…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x