Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Slinet6056 committed Sep 4, 2024
1 parent 7c8e5c4 commit 64f327a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ name: Test build

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
workflow_dispatch:

jobs:
build:
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*
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ 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"
args:
- ${{ inputs.package_name }}
- ${{ inputs.gpg_private_key }}
- ${{ inputs.gpg_passphrase }}
- ${{ inputs.pkgs_directory }}
21 changes: 15 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ set -e
pkgname=$1
gpg_private_key=$2
gpg_passphrase=$3
pkgdir=$4

# Create builder user
useradd builder -m
echo "builder ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers

# 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."
Expand All @@ -28,14 +29,22 @@ 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"
sudo -u builder bash <<EOF
export GPG_TTY=\$(tty)
echo "$gpg_private_key" | gpg --batch --import
if [ $? -ne 0 ]; then
echo "Failed to import GPG key"
exit 1
fi
echo "$gpg_passphrase" | gpg --batch --passphrase-fd 0 --pinentry-mode loopback -s /dev/null
if [ $? -ne 0 ]; then
echo "Failed to sign with GPG key"
exit 1
fi
# Build package
cd "$pkgbuild_dir"
makepkg -srf --sign --noconfirm
EOF

Expand Down

0 comments on commit 64f327a

Please sign in to comment.