From 3d8fd16d2a72c03dfd689d37d09d96e0fbace54f Mon Sep 17 00:00:00 2001 From: Siddharth Rawat Date: Wed, 1 Nov 2023 22:05:16 -0400 Subject: [PATCH] ci: add CI/CD pipelines for GitHub and Jenkins - Includes `Jenkinsfile` pipeline for semantic release (`.releaserc`) - GitHub actions workflow to validate the Helm Chart --- .github/workflows/helm-lint.yml | 27 +++++++++++++++++ .releaserc | 51 +++++++++++++++++++++++++++++++++ Jenkinsfile | 36 +++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 .github/workflows/helm-lint.yml create mode 100644 .releaserc create mode 100644 Jenkinsfile diff --git a/.github/workflows/helm-lint.yml b/.github/workflows/helm-lint.yml new file mode 100644 index 0000000..8f49de2 --- /dev/null +++ b/.github/workflows/helm-lint.yml @@ -0,0 +1,27 @@ +name: Helm Chart Validation + +on: + workflow_dispatch: + pull_request: + branches: [master] + +jobs: + lint: + name: Helm Chart Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Linting the Helm Chart + run: | + pwd + helm lint . + shell: bash + + - name: Generate a template + run: | + pwd + cd ../ + helm template webapp-helm-chart + shell: bash diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..a2222c9 --- /dev/null +++ b/.releaserc @@ -0,0 +1,51 @@ +{ + "branches": ["master"], + "repositoryUrl": "https://github.com/csye7125-fall2023-group05/infra-helm-chart.git", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + [ + "semantic-release-helm", + { + "chartPath": "./", + "onlyUpdateVersion": true + } + ], + [ + "@semantic-release/git", { + "assets": [ + {"path": "./Chart.yaml"}, + {"path": "./CHANGELOG.md"} + ] + }], + "@semantic-release/github" + ], + "release": { + "verifyConditions": { + "path": ["@semantic-release/changelog", "@semantic-release/github", "@semantic-release/git"] + }, + "analyzeCommits": [ + "@semantic-release/commit-analyzer" + ], + "generateNotes": [ + "@semantic-release/release-notes-generator", { + "preset": "angular", + "writerOpts": { + "commitsSort": ["header"] + } + } + ], + "prepare": [ + "semantic-release-helm", + "@semantic-release/git", + { + "path": "@semantic-release/changelog", + "changelogFile": "CHANGELOG.md" + } + ], + "publish": "@semantic-release/github", + "success": "@semantic-release/github", + "fail": "@semantic-release/github" + } +} diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..076894c --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,36 @@ +pipeline { + agent any + tools { nodejs "node" } + environment { + GH_TOKEN = credentials('jenkins-pat') + } + stages { + stage ('Checkout Code') { + steps { + cleanWs() + checkout scm + } + } + stage ('Release with SemVer') { + when { + branch 'master' + } + steps { + sh ''' + npm install @semantic-release/commit-analyzer + npm install @semantic-release/release-notes-generator + npm install @semantic-release/changelog + npm install semantic-release-helm + npm install @semantic-release/git + npm install @semantic-release/github + npx semantic-release + ''' + } + } + } + post { + always { + echo 'Pipeline complete' + } + } +} \ No newline at end of file