diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa1ec53..d47c123 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,15 @@ stages: - Tests - Build - - PostDeployPrep - - PostDeploy + - Update Deployment + - Create Commit + - Create Merge Request NodeJs Tests: stage: Tests image: node:22.14.0 + except: + - tags before_script: - cd frontend - npm install @@ -58,9 +61,48 @@ include: context: "frontend" dockerfile: "frontend/Dockerfile" - - project: 'shared/blueprints' - file: 'jobs/create-release.yml' - ref: master - rules: - - if: '$CI_COMMIT_TAG' +Update Deployment: + image: busybox:ubuntu + rules: + - if: '$CI_COMMIT_TAG' + stage: Update Deployment + script: | + echo "## Do not edit this file directly. It is auto-generated by the script." > argocd/deployment/deployment.yml + sed "s|__TAG__|${{ gitea.ref_name }}|g" argocd/template/deployment.yml >> argocd/deployment/deployment.yml + artifacts: + expire_in: 1 hour + paths: + - argocd/deployment/deployment.yml +Create Commit: + stage: Create Commit + dependencies: + - Update Deployment + image: alpine:3.18 + rules: + - if: '$CI_COMMIT_TAG' + before_script: | + git config --global user.name "${GITLAB_USER_NAME}" + git config --global user.email "${GITLAB_USER_EMAIL}" + script: | + git pull origin master + git checkout -b "update-deployment-${CI_COMMIT_TAG}" + git add argocd/deployment/deployment.yml + git commit -m "Update deployment manifest with new image tags" + git push origin "update-deployment-${CI_COMMIT_TAG}" + +Create Merge Request: + stage: Create Merge Request + dependencies: + - Create Commit + image: alpine:3.18 + rules: + - if: '$CI_COMMIT_TAG' + script: | + curl --request POST --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ + --data "source_branch=update-deployment-${CI_COMMIT_TAG}" \ + --data "target_branch=master" \ + --data "title=Update deployment manifest with new image tags" \ + --data "description=This merge request updates the deployment manifest with the new image tags." \ + --data "remove_source_branch=true" \ + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/merge_requests" \ No newline at end of file