ci: convert GitLab variables to Github actions

This commit is contained in:
Antoine Martin 2024-08-11 15:43:27 -04:00
parent 9a81361936
commit dee83b7b1b
Signed by: forge
GPG key ID: D62A472A4AA7D541
5 changed files with 17 additions and 18 deletions

View file

@ -13,4 +13,4 @@ shellcheck -s ash \
-e SC2030 \ -e SC2030 \
-e SC2031 \ -e SC2031 \
-e SC1090 \ -e SC1090 \
-xa $CI_PROJECT_DIR/.gitlab/bin/APKBUILD_SHIM -xa $GITHUB_WORKSPACE/.gitlab/bin/APKBUILD_SHIM

View file

@ -1,23 +1,23 @@
#!/bin/sh #!/bin/sh
# shellcheck disable=SC3043 # shellcheck disable=SC3043
. $CI_PROJECT_DIR/.gitlab/bin/functions.sh . $GITHUB_WORKSPACE/.gitlab/bin/functions.sh
# shellcheck disable=SC3040 # shellcheck disable=SC3040
set -eu -o pipefail set -eu -o pipefail
readonly APORTSDIR=$CI_PROJECT_DIR readonly APORTSDIR=$GITHUB_WORKSPACE
readonly REPOS="cross backports user testing community" readonly REPOS="cross backports user testing community"
readonly ALPINE_REPOS="main community" readonly ALPINE_REPOS="main community"
readonly ARCH=$(apk --print-arch) readonly ARCH=$(apk --print-arch)
# gitlab variables # gitlab variables
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME readonly BASEBRANCH=$GITHUB_BASE_REF
: "${REPODEST:=$HOME/packages}" : "${REPODEST:=$HOME/packages}"
: "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}" : "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}"
: "${ALPINE_MIRROR:=http://dl-cdn.alpinelinux.org/alpine}" : "${ALPINE_MIRROR:=http://dl-cdn.alpinelinux.org/alpine}"
: "${MAX_ARTIFACT_SIZE:=300000000}" #300M : "${MAX_ARTIFACT_SIZE:=300000000}" #300M
: "${CI_DEBUG_BUILD:=}" : "${RUNNER_DEBUG:=}"
: "${CI_ALPINE_BUILD_OFFSET:=0}" : "${CI_ALPINE_BUILD_OFFSET:=0}"
: "${CI_ALPINE_BUILD_LIMIT:=9999}" : "${CI_ALPINE_BUILD_LIMIT:=9999}"
@ -42,7 +42,7 @@ verbose() {
} }
debugging() { debugging() {
[ -n "$CI_DEBUG_BUILD" ] [ -n "$RUNNER_DEBUG" ]
} }
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 sudo cp $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub /etc/apk/keys/$ABUILD_KEY_NAME.rsa.pub
# patch abuild for crosscompiling # 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 sudo sed -i -E 's/export JOBS=[0-9]+$/export JOBS=$(nproc)/' /etc/abuild.conf
( . /etc/abuild.conf && echo "Building with $JOBS jobs" ) ( . /etc/abuild.conf && echo "Building with $JOBS jobs" )
@ -208,7 +208,7 @@ sudo chown -R $USER: .
fetch_flags="-qn" fetch_flags="-qn"
debugging && fetch_flags="-v" 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" "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH"
if debugging; then if debugging; then

View file

@ -14,7 +14,7 @@ basebranch=$1
if ! git rev-parse --verify --quiet $basebranch >/dev/null; then if ! git rev-parse --verify --quiet $basebranch >/dev/null; then
# The base branch does not eixst, probably due to a shallow clone # 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 fi
git --no-pager diff --diff-filter=ACMR --name-only $basebranch...HEAD -- "*/APKBUILD" | xargs -r -n1 dirname git --no-pager diff --diff-filter=ACMR --name-only $basebranch...HEAD -- "*/APKBUILD" | xargs -r -n1 dirname

View file

@ -4,7 +4,7 @@ BLUE="\e[34m"
MAGENTA="\e[35m" MAGENTA="\e[35m"
RESET="\e[0m" RESET="\e[0m"
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME readonly BASEBRANCH=$GITHUB_BASE_REF
verbose() { verbose() {
echo "> " "$@" echo "> " "$@"
@ -13,7 +13,7 @@ verbose() {
} }
debugging() { debugging() {
[ -n "$CI_DEBUG_BUILD" ] [ -n "$RUNNER_DEBUG" ]
} }
debug() { debug() {
@ -28,7 +28,7 @@ sudo chown -R gitlab-runner: .
fetch_flags="-qn" fetch_flags="-qn"
debugging && fetch_flags="-v" 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" "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH"
if debugging; then if debugging; then

View file

@ -2,14 +2,14 @@
# shellcheck disable=SC3043 # shellcheck disable=SC3043
. $CI_PROJECT_DIR/.gitlab/bin/functions.sh . $GITHUB_WORKSPACE/.gitlab/bin/functions.sh
# shellcheck disable=SC3040 # shellcheck disable=SC3040
set -eu -o pipefail set -eu -o pipefail
readonly APORTSDIR=$CI_PROJECT_DIR readonly APORTSDIR=$GITHUB_WORKSPACE
readonly REPOS="backports user" 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" 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 done
fetch_flags="-qn" 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" "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH"
for repo in $(changed_repos); do 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 for i in $(find $HOME/repo-apk/$repo -maxdepth 1 -mindepth 1 -printf '%P '); do
CHOST=$i abuild index CHOST=$i abuild index
done done
cd "$CI_PROJECT_DIR" cd "$GITHUB_WORKSPACE"
rm -R $repo/DUMMY rm -R $repo/DUMMY
done done
git -C $HOME/repo-apk add . 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 commit -m "Update from $CI_MERGE_REQUEST_IID - $CI_MERGE_REQUEST_TITLE"
git -C $HOME/repo-apk annex sync --content git -C $HOME/repo-apk annex sync --content