-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cicd): Update helm chart in CI-Merge
- Loading branch information
Showing
1 changed file
with
85 additions
and
40 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 |
---|---|---|
@@ -1,41 +1,86 @@ | ||
name: CI-Merge | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-24.04 | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
|
||
- name: Build the Docker image | ||
id: build_image | ||
run: | | ||
docker build -t ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:latest . | ||
name: CI-Merge | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
|
||
- name: Build the Docker image | ||
id: build_image | ||
run: | | ||
docker build -t ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:latest . | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push the Docker image | ||
run: | | ||
docker push ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:latest | ||
docker tag ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:latest ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:${{ steps.tag_version.outputs.new_tag }} | ||
docker push ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:${{ steps.tag_version.outputs.new_tag }} | ||
- name: Install GitHub CLI and yq | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gh | ||
sudo snap install yq | ||
- name: Clone Helm Chart Repository | ||
run: | | ||
git clone https://github.com/Star-Academy/Summer1403-Project-Group04-Deployment helm-chart-repo | ||
cd helm-chart-repo | ||
git checkout main | ||
- name: Update values.yaml for backend | ||
run: | | ||
echo "Updating values.yaml for backend..." | ||
cd helm-chart-repo | ||
yq eval ".backend.tag = \"${{ steps.tag_version.outputs.new_tag }}\"" -i values.yaml | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "muhuchah" | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push the Docker image | ||
run: | | ||
docker push ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:latest | ||
docker tag ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:latest ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:${{ steps.tag_version.outputs.new_tag }} | ||
docker push ${{ vars.DOCKERHUB_USERNAME }}/negar-backend:${{ steps.tag_version.outputs.new_tag }} | ||
# Create a new branch for the changes | ||
NEW_BRANCH="update-backend-tag-${{ steps.tag_version.outputs.new_tag }}" | ||
git checkout -b $NEW_BRANCH | ||
git add values.yaml | ||
git commit -m "Update backend tag to ${{ steps.tag_version.outputs.new_tag }}" | ||
- name: Push changes to new branch | ||
run: | | ||
cd helm-chart-repo | ||
git push origin $NEW_BRANCH | ||
- name: Create Pull Request | ||
run: | | ||
cd helm-chart-repo | ||
gh pr create --base main --head $NEW_BRANCH --title "Update backend tag to ${{ steps.tag_version.outputs.new_tag }}" --body "This PR updates the backend image tag to version ${{ steps.tag_version.outputs.new_tag }}." | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# - name: Deploy the Helm chart | ||
# run: | | ||
# cd helm-chart-repo | ||
# helm repo add my-repo <your-git-repo-url> | ||
# helm repo update | ||
# helm upgrade --install my-app my-repo/my-app --values values.yaml |