diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b09b58..2670c9f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Test build on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] workflow_dispatch: jobs: @@ -12,17 +12,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@master - - name: Build Package - uses: ./ - with: - package_name: ciallo - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} + - name: Build Package + uses: ./ + with: + package_name: ciallo + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} + pkgs_directory: test - - name: Upload Package - uses: actions/upload-artifact@main - with: - name: ciallo-package - path: test/ciallo/*.pkg.tar.zst* + - name: Upload Package + uses: actions/upload-artifact@main + with: + name: ciallo-package + path: test/ciallo/*.pkg.tar.zst* diff --git a/Dockerfile b/Dockerfile index 75c4d0a..55a4c9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,8 @@ FROM archlinux:base-devel RUN pacman -Syu --noconfirm RUN pacman -S git gnupg --noconfirm + COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index 4b02fcb..2bcc150 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,10 @@ inputs: gpg_passphrase: description: "GPG passphrase for building" required: true + pkgs_directory: + description: "Directory of package subdirectories" + required: false + default: "." runs: using: "docker" image: "Dockerfile" @@ -16,3 +20,4 @@ runs: - ${{ inputs.package_name }} - ${{ inputs.gpg_private_key }} - ${{ inputs.gpg_passphrase }} + - ${{ inputs.pkgs_directory }} diff --git a/entrypoint.sh b/entrypoint.sh index 3d83349..b2432f7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,13 +5,10 @@ set -e pkgname=$1 gpg_private_key=$2 gpg_passphrase=$3 - -# Create builder user -useradd builder -m -echo "builder ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +pkgdir=$4 # Find the PKGBUILD directory -pkgbuild_dir=$(readlink -f "$pkgname") +pkgbuild_dir=$(readlink -f "$pkgdir/$pkgname") if [[ ! -d $pkgbuild_dir ]]; then echo "$pkgbuild_dir should be a directory." @@ -23,19 +20,19 @@ if [[ ! -e $pkgbuild_dir/PKGBUILD ]]; then exit 1 fi -# Fix directory permissions +# Create builder user +useradd builder -m +echo "builder ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers chown -R builder:builder "$pkgbuild_dir" chown -R builder:builder /home/builder -# Import GPG key -echo "$gpg_private_key" | sudo -u builder gpg --import -echo "$gpg_passphrase" | sudo -u builder gpg --batch --passphrase-fd 0 --pinentry-mode loopback -s /dev/null - -# Build package -cd "$pkgbuild_dir" +# Import GPG key and build package sudo -u builder bash </dev/null 2>&1 + +cd "$pkgbuild_dir" makepkg -srf --sign --noconfirm EOF