Skip to content
Snippets Groups Projects
Commit 24a56728 authored by Gin Derick Magno's avatar Gin Derick Magno
Browse files

Update .gitlab-ci.yaml

parent b90c1357
No related branches found
No related tags found
No related merge requests found
image: node
stages: stages:
- check_build
- build - build
- set_tag
build:
stage: build
script:
- npm install
only:
- /^koda-chm-.*-stg$/
- /^koda-chm-.*-dev$/
variables: .setup:
VERSION: "1.0.0" before_script:
- LATEST_BUILD="$(tail -n 1 build.log)"
- ENVIRONMENT=$(echo "$CI_COMMIT_REF_NAME" | awk -F '-' '{print $NF}')
- PROJECT_NAME="${LATEST_BUILD%%-*}"
- PROJECT_NAME_WITH_ENV="${LATEST_BUILD%%-*}.$ENVIRONMENT"
- FORMATTED_PROJECT_NAME="${PROJECT_NAME_WITH_ENV//./-}"
- echo $FORMATTED_PROJECT_NAME
- CURRENT_DATE=$(date +%Y.%m.%d)
- VERSION=$(echo "$LATEST_BUILD" | awk -F '-' '{print $NF}')
- NEW_VERSION="${VERSION%.*}.$((${VERSION##*.} + 1))"
- NEW_BUILD="${PROJECT_NAME_WITH_ENV}-${CURRENT_DATE}-${NEW_VERSION}"
- NEW_BUILD_LOG="${PROJECT_NAME}-${CURRENT_DATE}-${NEW_VERSION}"
build_job: check_build:
stage: build extends: .setup
stage: check_build
script:
- if [[ "$CI_COMMIT_REF_NAME" != "$FORMATTED_PROJECT_NAME" ]]; then exit 1; fi
only:
- /^koda-chm-.*-stg$/
- /^koda-chm-.*-dev$/
.tag:
extends: .setup
stage: set_tag
set-tag-dev:
extends: .tag
script:
- |
echo "$NEW_BUILD_LOG" | tee -a build.log
git status
git fetch --tags
echo "$CI_COMMIT_REF_NAME"
git add build.log
# "[ci skip]" and "-o ci-skip" prevent a CI trigger loop
git commit -m "[ci skip] updated build $NEW_BUILD"
git push -o ci-skip https://oauth2:$ACCESS_TOKEN@gitlab.com/test-group1430/runner-testing.git HEAD:$CI_COMMIT_REF_NAME
#Tag commit (can be used without commiting files)
git tag "$NEW_BUILD"
git push --tags https://oauth2:$ACCESS_TOKEN@gitlab.com/test-group1430/runner-testing.git HEAD:$CI_COMMIT_REF_NAME
only:
- /^koda-chm-.*-dev$/
set-tag-stg:
extends: .tag
script: script:
- echo "Building version $VERSION" - |
- make build git status
git fetch --tags
echo "$CI_COMMIT_REF_NAME"
#Tag commit (can be used without commiting files)
git tag "$NEW_BUILD"
git push --tags https://oauth2:$ACCESS_TOKEN@gitlab.com/test-group1430/runner-testing.git HEAD:$CI_COMMIT_REF_NAME
only: only:
- main # Run the job only for the master branch (customize as needed) - /^koda-chm-.*-stg$/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment