From 4f4c7d06b16bea2ff50c2f7df363c4405860ca38 Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Wed, 27 Jul 2022 11:05:08 +0200 Subject: [PATCH] no message --- .gitlab-ci.yml | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b682e6..061c3f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,11 +4,11 @@ stages: - build services: - - name: griefed/gitlab-ci-cd:2.0.8 + - name: ghcr.io/griefed/gitlab-ci-cd:2.0.8 alias: docker command: ["--experimental"] -image: griefed/gitlab-ci-cd:2.0.8 +image: ghcr.io/griefed/gitlab-ci-cd:2.0.8 variables: project_name: $CI_PROJECT_NAME @@ -189,7 +189,7 @@ Check Packages:on-schedule: if [[ "$(git config --list | grep user.email)" != "user.email=$GIT_MAIL" ]];then git config --global user.email $GIT_MAIL fi - + # Clean system of potentially interrupting images docker image rm -f $DOCKERHUB_USER/$DOCKERHUB_REPO:latest docker image rm -f $DOCKERHUB_REPO @@ -202,74 +202,74 @@ Check Packages:on-schedule: # Clone the repository git clone $CI_PROJECT_URL.git /tmp/$CI_PROJECT_PATH && \ cd /tmp/$CI_PROJECT_PATH && \ - + if [ ! -s "package_versions.txt" ];then echo "No package_versions.txt present. Creating..." - + # Gather package information from latest build docker run --rm --entrypoint /bin/sh -v /tmp/$CI_PROJECT_PATH:/tmp $DOCKERHUB_USER/$DOCKERHUB_REPO:latest -c '\ apt list -qq --installed > /tmp/package_versions.txt && \ sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ chmod 777 /tmp/package_versions.txt' && \ - + # Checkout our branch git checkout -f $CI_DEFAULT_BRANCH && \ - + wait && \ - + # Add and commit new file to repository git add package_versions.txt && \ git commit -m 'chore: Add list of package versions.' && \ - + # Push the changes to the remote echo "https://***:***@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" git push "https://$GIT_USER:$GITLAB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH".git --all && \ - + # Nice - echo "package_versions.txt added." - + echo "package_versions.txt added." + elif [ -s "package_versions.txt" ];then echo "package_versions.txt present. Comapring..." - + # Build local image for new package versions list docker build --no-cache --tag $DOCKERHUB_REPO . && \ - + # Get packages from newly build local image docker run --rm --entrypoint /bin/sh -v /tmp/$CI_PROJECT_PATH:/tmp $DOCKERHUB_REPO -c '\ apt list -qq --installed > /tmp/package_versions_new.txt && \ sort -o /tmp/package_versions_new.txt /tmp/package_versions_new.txt && \ chmod 777 /tmp/package_versions_new.txt' && \ - + # Get checksum of old packages OLD_CHECKSUM=$(md5sum package_versions.txt | cut -f1 -d" ") && \ - + # Get checksum of new packages NEW_CHECKSUM=$(md5sum package_versions_new.txt | cut -f1 -d" ") && \ - + # If new checksum is not the same as old checksum, we have new versions if [ "${OLD_CHECKSUM}" != "${NEW_CHECKSUM}" ]; then - + # Checkout our branch git checkout -f $CI_DEFAULT_BRANCH && \ - + # Copy the new package versions list to repository mv -f package_versions_new.txt package_versions.txt && \ - + wait && \ - + # Add and commit new file to repository git add package_versions.txt && \ - git commit -m 'build: Update installed packages.' && \ - + git commit -m 'build: Update installed packages in Docker container.' && \ + # Push the changes to the remote git push "https://$GIT_USER:$GITLAB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" --all && \ - + # Nice echo "Packages updated." else echo "No package updates available." fi - + fi echo "Comparison complete." after_script: -- GitLab