From 562e2e872a520dcddf57737732d78f26a325e2ae Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 16:13:47 +0000 Subject: [PATCH 1/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..64b372d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,49 @@ +# This file is a template, and might need editing before it works on your project. +# This is a sample GitLab CI/CD configuration file that should run without any modifications. +# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, +# it uses echo commands to simulate the pipeline execution. +# +# A pipeline is composed of independent jobs that run scripts, grouped into stages. +# Stages run in sequential order, but jobs within stages run in parallel. +# +# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages +# +# You can copy and paste this template into a new `.gitlab-ci.yml` file. +# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. +# +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml + +stages: # List of stages for jobs, and their order of execution + - build + - test + - deploy + +build-job: # This job runs in the build stage, which runs first. + stage: build + script: + - echo "Compiling the code..." + - echo "Compile complete." + +unit-test-job: # This job runs in the test stage. + stage: test # It only starts when the job in the build stage completes successfully. + script: + - echo "Running unit tests... This will take about 60 seconds." + - sleep 60 + - echo "Code coverage is 90%" + +lint-test-job: # This job also runs in the test stage. + stage: test # It can run at the same time as unit-test-job (in parallel). + script: + - echo "Linting code... This will take about 10 seconds." + - sleep 10 + - echo "No lint issues found." + +deploy-job: # This job runs in the deploy stage. + stage: deploy # It only runs when *both* jobs in the test stage complete successfully. + environment: production + script: + - echo "Deploying application..." + - echo "Application successfully deployed." From 9b335ef7f8290742601f1b830f02d0e3c1b37072 Mon Sep 17 00:00:00 2001 From: VRSasha Date: Sun, 30 Jul 2023 23:39:40 +0700 Subject: [PATCH 2/9] remove comments --- .gitlab-ci.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 64b372d..d9e922e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,21 +1,3 @@ -# This file is a template, and might need editing before it works on your project. -# This is a sample GitLab CI/CD configuration file that should run without any modifications. -# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, -# it uses echo commands to simulate the pipeline execution. -# -# A pipeline is composed of independent jobs that run scripts, grouped into stages. -# Stages run in sequential order, but jobs within stages run in parallel. -# -# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages -# -# You can copy and paste this template into a new `.gitlab-ci.yml` file. -# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. -# -# To contribute improvements to CI/CD templates, please follow the Development guide at: -# https://docs.gitlab.com/ee/development/cicd/templates.html -# This specific template is located at: -# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml - stages: # List of stages for jobs, and their order of execution - build - test From baecb2a465cc8786143c08a350cef26504c0052f Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 17:10:01 +0000 Subject: [PATCH 3/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9e922e..3fe7986 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,27 +1,24 @@ stages: # List of stages for jobs, and their order of execution + - prepare - build - - test - deploy -build-job: # This job runs in the build stage, which runs first. - stage: build +remove-old-services: # This job runs in the build stage, which runs first. + stage: prepare script: - - echo "Compiling the code..." - - echo "Compile complete." + - podman stop little-lines + - podman rm little-lines -unit-test-job: # This job runs in the test stage. - stage: test # It only starts when the job in the build stage completes successfully. +apply-version-tag: + stage: prepare script: - - echo "Running unit tests... This will take about 60 seconds." - - sleep 60 - - echo "Code coverage is 90%" + - sed -i "s/DATE/$(date -I)/g" src/views/Setting.vue + - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" src/views/Setting.vue -lint-test-job: # This job also runs in the test stage. - stage: test # It can run at the same time as unit-test-job (in parallel). +build-job: # This job runs in the test stage. + stage: build # It only starts when the job in the build stage completes successfully. script: - - echo "Linting code... This will take about 10 seconds." - - sleep 10 - - echo "No lint issues found." + - podman build -t little-lines:$(git log -1 --oneline | awk '{print $1}') . deploy-job: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. From cbbfc9e841e5e5c6cff4503808864472507d8d8b Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 17:21:52 +0000 Subject: [PATCH 4/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3fe7986..1371be0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,8 @@ build-job: # This job runs in the test stage. deploy-job: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. - environment: production script: - - echo "Deploying application..." - - echo "Application successfully deployed." + - podman run --name little-lines -p 8081:80 -d little-lines:$(git log -1 --oneline | awk '{print $1}') + - podman generate systemd little-lines > ~/.config/systemd/user/little-lines.service + - systemctl --user daemon-reload + - systemctl --user enable little-lines \ No newline at end of file From 1ddd34cca7d3d1627d682464babf5ba75389cf81 Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 17:49:48 +0000 Subject: [PATCH 5/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1371be0..859d73c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,8 +12,8 @@ remove-old-services: # This job runs in the build stage, which runs first. apply-version-tag: stage: prepare script: - - sed -i "s/DATE/$(date -I)/g" src/views/Setting.vue - - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" src/views/Setting.vue + - sed -i "s/DATE/$(date -I)/g" ${CI_PROJECT_DIR}/src/views/Setting.vue + - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" ${CI_PROJECT_DIR}/src/views/Setting.vue build-job: # This job runs in the test stage. stage: build # It only starts when the job in the build stage completes successfully. From 383c7d38a351fdc37256ae55471165a3a9b04a1a Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 17:58:13 +0000 Subject: [PATCH 6/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 859d73c..5bafbeb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,8 @@ remove-old-services: # This job runs in the build stage, which runs first. apply-version-tag: stage: prepare script: + - echo $CI_PROJECT_DIR + - echo ${CI_PROJECT_DIR} - sed -i "s/DATE/$(date -I)/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" ${CI_PROJECT_DIR}/src/views/Setting.vue From f31f118d59ac520771f8b9546ce06ff8fab1a7c5 Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 18:02:59 +0000 Subject: [PATCH 7/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5bafbeb..1e95d6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,17 +9,11 @@ remove-old-services: # This job runs in the build stage, which runs first. - podman stop little-lines - podman rm little-lines -apply-version-tag: - stage: prepare - script: - - echo $CI_PROJECT_DIR - - echo ${CI_PROJECT_DIR} - - sed -i "s/DATE/$(date -I)/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - build-job: # This job runs in the test stage. stage: build # It only starts when the job in the build stage completes successfully. script: + - sed -i "s/DATE/$(date -I)/g" ${CI_PROJECT_DIR}/src/views/Setting.vue + - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - podman build -t little-lines:$(git log -1 --oneline | awk '{print $1}') . deploy-job: # This job runs in the deploy stage. From 72215868185a2280476a210a6d782ffb0f2fb820 Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Sun, 30 Jul 2023 18:13:42 +0000 Subject: [PATCH 8/9] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e95d6f..25c046a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,23 +1,23 @@ -stages: # List of stages for jobs, and their order of execution +stages: - prepare - build - deploy -remove-old-services: # This job runs in the build stage, which runs first. +remove-old-services: stage: prepare script: - podman stop little-lines - podman rm little-lines -build-job: # This job runs in the test stage. - stage: build # It only starts when the job in the build stage completes successfully. +container-build: + stage: build script: - sed -i "s/DATE/$(date -I)/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - podman build -t little-lines:$(git log -1 --oneline | awk '{print $1}') . -deploy-job: # This job runs in the deploy stage. - stage: deploy # It only runs when *both* jobs in the test stage complete successfully. +container-deploy: + stage: deploy script: - podman run --name little-lines -p 8081:80 -d little-lines:$(git log -1 --oneline | awk '{print $1}') - podman generate systemd little-lines > ~/.config/systemd/user/little-lines.service From e0879c51f86c76248fe708db1c0652837b1078af Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Mon, 31 Jul 2023 16:36:53 +0000 Subject: [PATCH 9/9] make deployment process auto replace old containers --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25c046a..2debc71 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,12 +14,12 @@ container-build: script: - sed -i "s/DATE/$(date -I)/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - sed -i "s/VERSION/$(git log -1 --oneline | awk '{print $1}')/g" ${CI_PROJECT_DIR}/src/views/Setting.vue - - podman build -t little-lines:$(git log -1 --oneline | awk '{print $1}') . + - podman build -t little-lines . container-deploy: stage: deploy script: - - podman run --name little-lines -p 8081:80 -d little-lines:$(git log -1 --oneline | awk '{print $1}') + - podman run --name little-lines -p 8081:80 -d little-lines - podman generate systemd little-lines > ~/.config/systemd/user/little-lines.service - systemctl --user daemon-reload - systemctl --user enable little-lines \ No newline at end of file