From dee83b7b1bfe29e082c868cd1ccfe425efa7c0b8 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 11 Aug 2024 15:43:27 -0400 Subject: [PATCH] ci: convert GitLab variables to Github actions --- .gitlab/bin/apkbuild-shellcheck | 2 +- .gitlab/bin/build.sh | 14 +++++++------- .gitlab/bin/changed-aports | 2 +- .gitlab/bin/lint | 6 +++--- .gitlab/bin/push.sh | 11 +++++------ 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.gitlab/bin/apkbuild-shellcheck b/.gitlab/bin/apkbuild-shellcheck index 3126684..5df3718 100755 --- a/.gitlab/bin/apkbuild-shellcheck +++ b/.gitlab/bin/apkbuild-shellcheck @@ -13,4 +13,4 @@ shellcheck -s ash \ -e SC2030 \ -e SC2031 \ -e SC1090 \ - -xa $CI_PROJECT_DIR/.gitlab/bin/APKBUILD_SHIM + -xa $GITHUB_WORKSPACE/.gitlab/bin/APKBUILD_SHIM diff --git a/.gitlab/bin/build.sh b/.gitlab/bin/build.sh index 286f965..4a6b812 100755 --- a/.gitlab/bin/build.sh +++ b/.gitlab/bin/build.sh @@ -1,23 +1,23 @@ #!/bin/sh # shellcheck disable=SC3043 -. $CI_PROJECT_DIR/.gitlab/bin/functions.sh +. $GITHUB_WORKSPACE/.gitlab/bin/functions.sh # shellcheck disable=SC3040 set -eu -o pipefail -readonly APORTSDIR=$CI_PROJECT_DIR +readonly APORTSDIR=$GITHUB_WORKSPACE readonly REPOS="cross backports user testing community" readonly ALPINE_REPOS="main community" readonly ARCH=$(apk --print-arch) # gitlab variables -readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME +readonly BASEBRANCH=$GITHUB_BASE_REF : "${REPODEST:=$HOME/packages}" : "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}" : "${ALPINE_MIRROR:=http://dl-cdn.alpinelinux.org/alpine}" : "${MAX_ARTIFACT_SIZE:=300000000}" #300M -: "${CI_DEBUG_BUILD:=}" +: "${RUNNER_DEBUG:=}" : "${CI_ALPINE_BUILD_OFFSET:=0}" : "${CI_ALPINE_BUILD_LIMIT:=9999}" @@ -42,7 +42,7 @@ verbose() { } debugging() { - [ -n "$CI_DEBUG_BUILD" ] + [ -n "$RUNNER_DEBUG" ] } debug() { @@ -152,7 +152,7 @@ setup_system() { sudo cp $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub /etc/apk/keys/$ABUILD_KEY_NAME.rsa.pub # patch abuild for crosscompiling - sudo patch -p1 -d / -i $CI_PROJECT_DIR/.gitlab/patches/abuild-cross.patch + sudo patch -p1 -d / -i $GITHUB_WORKSPACE/.gitlab/patches/abuild-cross.patch sudo sed -i -E 's/export JOBS=[0-9]+$/export JOBS=$(nproc)/' /etc/abuild.conf ( . /etc/abuild.conf && echo "Building with $JOBS jobs" ) @@ -208,7 +208,7 @@ sudo chown -R $USER: . fetch_flags="-qn" debugging && fetch_flags="-v" -git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \ +git fetch $fetch_flags "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH" if debugging; then diff --git a/.gitlab/bin/changed-aports b/.gitlab/bin/changed-aports index 4541230..bd6f3ae 100755 --- a/.gitlab/bin/changed-aports +++ b/.gitlab/bin/changed-aports @@ -14,7 +14,7 @@ basebranch=$1 if ! git rev-parse --verify --quiet $basebranch >/dev/null; then # The base branch does not eixst, probably due to a shallow clone - git fetch -v $CI_MERGE_REQUEST_PROJECT_URL.git +refs/heads/$basebranch:refs/heads/$basebranch + git fetch -v $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git +refs/heads/$basebranch:refs/heads/$basebranch fi git --no-pager diff --diff-filter=ACMR --name-only $basebranch...HEAD -- "*/APKBUILD" | xargs -r -n1 dirname diff --git a/.gitlab/bin/lint b/.gitlab/bin/lint index c1edcfb..7dd95d8 100755 --- a/.gitlab/bin/lint +++ b/.gitlab/bin/lint @@ -4,7 +4,7 @@ BLUE="\e[34m" MAGENTA="\e[35m" RESET="\e[0m" -readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME +readonly BASEBRANCH=$GITHUB_BASE_REF verbose() { echo "> " "$@" @@ -13,7 +13,7 @@ verbose() { } debugging() { - [ -n "$CI_DEBUG_BUILD" ] + [ -n "$RUNNER_DEBUG" ] } debug() { @@ -28,7 +28,7 @@ sudo chown -R gitlab-runner: . fetch_flags="-qn" debugging && fetch_flags="-v" -git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \ +git fetch $fetch_flags "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH" if debugging; then diff --git a/.gitlab/bin/push.sh b/.gitlab/bin/push.sh index 0a11b0b..d440133 100755 --- a/.gitlab/bin/push.sh +++ b/.gitlab/bin/push.sh @@ -2,14 +2,14 @@ # shellcheck disable=SC3043 -. $CI_PROJECT_DIR/.gitlab/bin/functions.sh +. $GITHUB_WORKSPACE/.gitlab/bin/functions.sh # shellcheck disable=SC3040 set -eu -o pipefail -readonly APORTSDIR=$CI_PROJECT_DIR +readonly APORTSDIR=$GITHUB_WORKSPACE readonly REPOS="backports user" -readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME +readonly BASEBRANCH=$GITHUB_BASE_REF export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" @@ -38,7 +38,7 @@ for i in $(find packages -type f -name "*.apk"); do done fetch_flags="-qn" -git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \ +git fetch $fetch_flags "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH" for repo in $(changed_repos); do @@ -49,10 +49,9 @@ for repo in $(changed_repos); do for i in $(find $HOME/repo-apk/$repo -maxdepth 1 -mindepth 1 -printf '%P '); do CHOST=$i abuild index done - cd "$CI_PROJECT_DIR" + cd "$GITHUB_WORKSPACE" rm -R $repo/DUMMY done - git -C $HOME/repo-apk add . git -C $HOME/repo-apk commit -m "Update from $CI_MERGE_REQUEST_IID - $CI_MERGE_REQUEST_TITLE" git -C $HOME/repo-apk annex sync --content