ci: Run main GH action CI build+test as non-root
authorColin Walters <walters@verbum.org>
Thu, 26 Aug 2021 13:53:56 +0000 (09:53 -0400)
committerColin Walters <walters@verbum.org>
Thu, 26 Aug 2021 18:40:34 +0000 (14:40 -0400)
This is really the standard best practice, matching how
e.g. dpkg/rpm work, as well as most local development
environments (including mine) with e.g. `toolbox`.

.github/workflows/tests.yml

index df1b1e07e7e6c508bb019040cf87e74871ba40f2..c17a1c0dfb5d1df6d6f853d0da3ca67c55f3717b 100644 (file)
@@ -120,8 +120,11 @@ jobs:
       - name: Install dependencies
         run: ./ci/gh-install.sh ${{ matrix.extra-packages }}
 
+      - name: Add non-root user
+        run: "useradd builder && chown -R -h builder: ."
+
       - name: Build and test
-        run: ./ci/gh-build.sh ${{ matrix.configure-options }}
+        run: runuser -u builder -- ./ci/gh-build.sh ${{ matrix.configure-options }}
         env:
           # GitHub hosted runners currently have 2 CPUs, so run 2
           # parallel make jobs.