WEEK-5: updated the README.md #6
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
name: Go App CI/CD | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
Run-Tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' # Make sure this matches your go.mod file | |
- name: run tests | |
run: go test -v ./... | |
Build-Push: | |
needs: Run-Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build Docker image | |
run: | | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/devops-journey:latest . | |
- name: Push Docker image | |
run: | | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/devops-journey:latest | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.12.0 # Specify the Helm version you want to use | |
- name: Package Helm chart | |
run: | | |
helm package ./helm-chart | |
- name: Upload Helm chart as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: helm-chart | |
path: devops-journey-0.1.0.tgz | |
DEV-Deploy: | |
needs: Build-Push | |
runs-on: self-hosted # deploying to local k8s cluster | |
steps: | |
- name: Download Helm chart | |
uses: actions/download-artifact@v4 | |
with: | |
name: helm-chart | |
path: chart/ | |
- name: deploy-to-dev | |
run: | | |
helm upgrade --install devops-journey chart/devops-journey-0.1.0.tgz -n dev | |
echo "Deployed to dev successfully!!" | |
QA-Deploy: | |
needs: DEV-Deploy | |
runs-on: self-hosted # deploying to local k8s cluster | |
steps: | |
- name: Download Helm chart | |
uses: actions/download-artifact@v4 | |
with: | |
name: helm-chart | |
path: chart/ | |
- name: deploy-to-qa | |
run: | | |
helm upgrade --install devops-journey chart/devops-journey-0.1.0.tgz -n qa | |
echo "Deployed to QA successfully!!" | |
Prod-Deploy: | |
needs: QA-Deploy | |
runs-on: self-hosted # deploying to local k8s cluster | |
steps: | |
- name: Download Helm chart | |
uses: actions/download-artifact@v4 | |
with: | |
name: helm-chart | |
path: chart/ | |
- name: deploy-to-prod | |
run: | | |
helm upgrade --install devops-journey chart/devops-journey-0.1.0.tgz -n prod | |
echo "Deployed to Prod successfully!!" | |