Step-by-Step Guide to Creating a CI/CD Pipeline on GitHub | by Hasan Coskun | Oct, 2024

GitHub provides a centralized repository for your projects. Follow these steps to create and use a new repository:
1. Log into your GitHub account and click on “New Repository”.
2. Set the repository name, description, and privacy settings.
3. Click “Create Repository” to create a new repository.

To add code to the new repository via terminal:
1. Clone the project with Git:
git clone https://github.com/user/repo.git
2. Add changes and commit them:
git add .
git commit -m “Initial commit”
3. Push the changes to GitHub:
git push origin master

To improve code quality, you can use static code analysis tools. Tools like SonarQube or CodeQL can be integrated into GitHub Actions.
Here is an example step in a GitHub Action pipeline:

name: Code Analysis
on: [push]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run CodeQL Analysis
uses: github/codeql-action/init@v1
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

This process will automatically analyze your code every time you push changes.

You can use GitHub Actions to check for security vulnerabilities in your code. Tools like Dependabot automatically handle security updates.
To use Dependabot, enable it in your repository settings under the “Security & analysis” tab. Additionally, you can add security check steps to your GitHub Actions pipeline:

name: Security Check
on: [push]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Security Analysis
run: |
npm install
npm audit

This step will scan for security vulnerabilities in your project.

To deploy to OpenShift automatically, you can use GitHub Actions and the OpenShift CLI. First, configure the OpenShift CLI in your GitHub Actions environment.

name: Deploy to OpenShift
on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to OpenShift
run: |
oc login - token=$OPENSHIFT_TOKEN - server=$OPENSHIFT_SERVER

- name: Deploy to OpenShift
run: |
oc apply -f deployment.yaml
oc rollout status deployment/my-app

This process will automatically deploy to OpenShift when new code is pushed.