What is CI-CD?
Continous Integration is a development practice that requires developers to integrate code into a shared repository several times a day.A source code version control system is the core of the CI process.
Continuous Delivery (CD) is the ability to get changes of all types including new features, configuration changes, bug fixes and experiments into production.
Benefits of CI-CD
Faster identification and resolution of defects
Reduced overhead cost
Better quality assurance
Reduced Assumptions
CI-CD pipeline using Github Actions:
- GitHub Actions is a powerful automation tool, that provides an excellent platform to create and manage CI/CD pipeline using GitHub workflows.
Steps involved in GitHub Actions
Create a github repo
Create a settings.xml
Create a workflow action using .yaml file
Setup the repository secrets
Execute the pipeline workflow
Create a Github repo
Click repositories >> New >> Add Name >> Select public repo for GitHub Actions >> Create Repo.
Create a Settings.xml
Create folder .maven in root folder of repo and create settings.xml file inside that.
Create a workflow using github actions
Go to github repo-> Actions -> Choose the workflow -> Java with Maven (Add the below configuration in the .yml file)
name: Mule CI with Mule Maven
on: push: branches: [ "main" ] pull_request: branches: [ "main" ]
env:
NEXUS_USERNAME: ${{ secrets.NEXUSUSERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUSPASSWORD }}
PLATFORM_USERNAME: ${{ secrets.PLATFORMUSERNAME }} PLATFORM_PASSWORD: ${{ secrets.PLATFORMPASSWORD }}
ENVIRONMENT: ${{ secrets.ENVIRONMENT}}
jobs: build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' cache: maven
#third, build with Maven - name: Build with Maven run:
mvn -B clean package -s .maven/settings.xml
#fourth, upload artifact, to utilize for other repo.(optional) - name:
upload Artifact run: mkdir staging && cp target/*.jar staging - uses: actions/upload-artifact@v4 with: name: Package path: staging
#fifth, Deploy with Maven - name:
Deploy run: mvn deploy -DskipMunitTests -DmuleDeploy -Danypoint.username="$PLATFORM_USERNAME" -Danypoint.password="$PLATFORM_PASSWORD"
Create a configuration in pom.xml
Setup the repository secrets:
Go to Repo Settings-> Secrets and Variables-> New Repository Secret
Execute a workflow pipeline
When the code is pushed to repo it will trigger the workflow