Skip to content

Update the workflow for deploy to dev #11

Update the workflow for deploy to dev

Update the workflow for deploy to dev #11

Workflow file for this run

name: Go App CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
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-and-push:
needs: test
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: devops-journey-chart
path: devops-journey-*.tgz
deploy:
needs: build-and-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: ./
- name: deploy-to-dev
run: |
helm upgrade --install devops-journey devops-journey-chart.tgz -n dev
echo "Deployed to dev successfully!!"