diff --git a/.ci/kconfig.sh b/.ci/kconfig.sh
new file mode 100755
index 0000000000000000000000000000000000000000..4599b1fa7fa291e4f5365e427cb3807fd41011f5
--- /dev/null
+++ b/.ci/kconfig.sh
@@ -0,0 +1,22 @@
+#!/bin/sh -e
+# Description: check all kernel configs with 'pmbootstrap kconfig check'
+# Options: native
+# Use 'native' because it requires running pmbootstrap.
+# https://postmarktos.org/pmb-ci
+
+if [ "$(id -u)" = 0 ]; then
+	set -x
+	wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
+	sh ./install_pmbootstrap.sh
+	exec su "${TESTUSER:-pmos}" -c "sh -e $0"
+fi
+
+# Wrap pmbootstrap to use this repository for --aports
+pmaports="$(cd $(dirname $0)/..; pwd -P)"
+_pmbootstrap="$(command -v pmbootstrap)"
+pmbootstrap() {
+	"$_pmbootstrap" --aports="$pmaports" "$@"
+}
+
+set -x
+pmbootstrap kconfig check
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0be7187727fbf170f1c0b48b6c4fb815ccd9dafd..baafb25cc4f9397364937db654d4dcd27ca135ea 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -117,11 +117,9 @@ kernel-kconfig:
     changes:
       - device/*/linux-*/config-*
       - main/linux-*/config-*
-  before_script:
-    - wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
-    - sh ./install_pmbootstrap.sh pytest
   script:
-    - su pmos -c "pmbootstrap kconfig check"
+    - .ci/lib/gitlab_prepare_ci.sh
+    - .ci/kconfig.sh
 
 # MR settings
 # (Checks for "Allow commits from members who can merge to the target branch")