From f6e7ddc14a500299caed91c0f4ff8bb5fb2e2d0d Mon Sep 17 00:00:00 2001 From: Rama-1604 <134438243+Rama-1604@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:06:09 +0530 Subject: [PATCH 1/2] Create cicd.yml --- .github/workflows/cicd.yml | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 000000000..6a879092d --- /dev/null +++ b/.github/workflows/cicd.yml @@ -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.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push action + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_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 "abhishek@gmail.com" + git config --global user.name "Abhishek Veeramalla" + git add helm/go-web-app-chart/values.yaml + git commit -m "Update tag in Helm chart" + git push + From 479f981dea2559cba018ee557174dd7a7a0db7d7 Mon Sep 17 00:00:00 2001 From: Rama-1604 <134438243+Rama-1604@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:01:13 +0530 Subject: [PATCH 2/2] Delete .github/workflows directory --- .github/workflows/cicd.yml | 95 -------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml deleted file mode 100644 index 6a879092d..000000000 --- a/.github/workflows/cicd.yml +++ /dev/null @@ -1,95 +0,0 @@ -# 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.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and Push action - uses: docker/build-push-action@v6 - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ secrets.DOCKERHUB_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 "abhishek@gmail.com" - git config --global user.name "Abhishek Veeramalla" - git add helm/go-web-app-chart/values.yaml - git commit -m "Update tag in Helm chart" - git push -