You've already forked reloading-manager
111 lines
3.1 KiB
YAML
111 lines
3.1 KiB
YAML
stages:
|
|
- Tests
|
|
- Build
|
|
- Update Deployment
|
|
- Create Commit
|
|
- Create Merge Request
|
|
|
|
NodeJs Tests:
|
|
stage: Tests
|
|
image: node:22.14.0
|
|
except:
|
|
- tags
|
|
before_script:
|
|
- cd frontend
|
|
- npm install
|
|
script:
|
|
- npm run build
|
|
|
|
include:
|
|
- project: 'shared/blueprints'
|
|
file: 'jobs/golang-tests.yml'
|
|
ref: master
|
|
inputs:
|
|
job_name: "Go Tests"
|
|
working_directory: "backend"
|
|
stage: Tests
|
|
|
|
- project: 'shared/blueprints'
|
|
file: 'jobs/docker-build.yml'
|
|
ref: master
|
|
rules:
|
|
- if: '$CI_COMMIT_TAG'
|
|
inputs:
|
|
jobName: "build backend"
|
|
dockerHubUser: ${DOCKER_HUB_USER}
|
|
dockerHubPat: ${DOCKER_HUB_PAT}
|
|
registry: "scr.siteworxpro.com"
|
|
registryUser: ${REGISTRY_USER}
|
|
registryPassword: ${REGISTRY_PASSWORD}
|
|
stage: Build
|
|
repo: "scr.siteworxpro.com/reloading-manager/backend"
|
|
tag: "${CI_COMMIT_TAG}"
|
|
context: "backend"
|
|
dockerfile: "backend/Dockerfile"
|
|
|
|
- project: 'shared/blueprints'
|
|
file: 'jobs/docker-build.yml'
|
|
ref: master
|
|
rules:
|
|
- if: '$CI_COMMIT_TAG'
|
|
inputs:
|
|
jobName: "build frontend"
|
|
dockerHubUser: ${DOCKER_HUB_USER}
|
|
dockerHubPat: ${DOCKER_HUB_PAT}
|
|
registry: "scr.siteworxpro.com"
|
|
registryUser: ${REGISTRY_USER}
|
|
registryPassword: ${REGISTRY_PASSWORD}
|
|
stage: Build
|
|
repo: "scr.siteworxpro.com/reloading-manager/frontend"
|
|
tag: "${CI_COMMIT_TAG}"
|
|
context: "frontend"
|
|
dockerfile: "frontend/Dockerfile"
|
|
|
|
Update Deployment:
|
|
image: alpine:3.18
|
|
rules:
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: on_success
|
|
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__|${CI_COMMIT_TAG}|g" argocd/template/deployment.yml >> argocd/deployment/deployment.yml
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- argocd/deployment/deployment.yml
|
|
|
|
Create Commit:
|
|
stage: Create Commit
|
|
rules:
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: on_success
|
|
dependencies:
|
|
- Update Deployment
|
|
image: siteworxpro/git:2.49.0
|
|
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'
|
|
when: on_success
|
|
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" |