-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
niveshsunny
committed
Aug 30, 2024
1 parent
134a9b0
commit eee6d02
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
# CICD using GitHub actions | ||
|
||
name: CI/CD | ||
|
||
# Exclude the workflow to run on changes to the helm chart | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- 'helm/**' | ||
- 'k8s/**' | ||
- 'README.md' | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go 1.22 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.22 | ||
|
||
- name: Build | ||
run: go build -o go-web-app | ||
|
||
- name: Test | ||
run: go test ./... | ||
|
||
code-quality: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.56.2 | ||
|
||
push: | ||
runs-on: ubuntu-latest | ||
|
||
needs: build | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Build and Push action | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/go-web-app:${{github.run_id}} | ||
|
||
update-newtag-in-helm-chart: | ||
runs-on: ubuntu-latest | ||
|
||
needs: push | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.TOKEN }} | ||
|
||
- name: Update tag in Helm chart | ||
run: | | ||
sed -i 's/tag: .*/tag: "${{github.run_id}}"/' helm/go-web-app-chart/values.yaml | ||
- name: Commit and push changes | ||
run: | | ||
git config --global user.email "niveshreddy963@gmail.com" | ||
git config --global user.name "niveshsunny" | ||
git add helm/go-web-app-chart/values.yaml | ||
git commit -m "Update tag in Helm chart" | ||
git push |