.mirror/action.yml

86 lines
3.2 KiB
YAML
Raw Normal View History

2023-03-25 13:25:57 +01:00
name: 'Mirror'
description: 'Test and Mirror AUR Packages'
inputs:
pkgbase:
description: 'The pkgbase from the AUR.'
required: false
ssh_key:
description: 'The base64-part of the private key to upload to the AUR.'
required: true
runs:
using: "composite"
steps:
2023-03-25 13:25:57 +01:00
- name: Test AUR package
uses: docker://docker.io/library/archlinux:base-devel
with:
2023-03-25 13:39:10 +01:00
entrypoint: bash
2023-03-25 13:40:12 +01:00
args: |
2023-03-25 14:11:54 +01:00
-exuo pipefail -c '
2023-03-25 13:51:03 +01:00
pacman -Syu --noconfirm git
2023-03-25 13:53:10 +01:00
2023-03-25 13:51:03 +01:00
useradd -m user
echo "user ALL=(ALL:ALL) NOPASSWD: ALL" >/etc/sudoers.d/user
2023-03-25 13:53:10 +01:00
sudo -u user -- bash -c "cd ~ && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si --noconfirm"
2023-03-25 14:17:05 +01:00
echo "#!/bin/bash -ex" >/usr/local/bin/yay.sh
echo "sudo -u user -- yay \"\${@}\"" >>/usr/local/bin/yay.sh
chmod +x /usr/local/bin/yay.sh
2023-03-25 13:53:10 +01:00
2023-03-25 13:51:03 +01:00
chmod 777 .
2023-03-25 14:17:05 +01:00
sudo -u user PACMAN="/usr/local/bin/yay.sh" makepkg -s --noconfirm
2023-03-25 14:11:54 +01:00
sudo -u user makepkg --printsrcinfo >.SRCINFO.new
2023-03-25 13:51:03 +01:00
'
2023-03-25 13:25:57 +01:00
- name: Ensure .SRCINFO is up to date
2023-03-25 14:09:06 +01:00
run: diff -u .SRCINFO .SRCINFO.new
2023-03-25 13:25:57 +01:00
- name: Mirror to the AUR
run: |
2023-03-25 23:08:39 +01:00
mkdir -p ~/.ssh
2024-11-25 22:32:30 +01:00
echo "-----BEGIN OPENSSH PRIVATE KEY-----" >~/.ssh/ssh_key
echo '${{inputs.ssh_key}}' >>~/.ssh/ssh_key
echo "-----END OPENSSH PRIVATE KEY-----" >>~/.ssh/ssh_key
2023-03-25 13:25:57 +01:00
echo 'aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN' >>~/.ssh/known_hosts
2023-03-25 23:08:39 +01:00
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
2023-03-25 13:25:57 +01:00
pkgbase='${{inputs.pkgbase}}'
[ -n "$pkgbase" ] || pkgbase="$( (. PKGBUILD && printf '%s' "$pkgbase") )"
[ -n "$pkgbase" ] || pkgbase="$( (. PKGBUILD && printf '%s' "$pkgname") )"
2024-12-09 00:41:40 +01:00
pkgver="$( (. PKGBUILD && printf '%s' "$pkgver") )"
pkgrel="$( (. PKGBUILD && printf '%s' "$pkgrel") )"
2023-03-25 13:25:57 +01:00
[ -n "$pkgbase" ] || \
( echo "Failed to determine pkgbase"; exit 1 )
[ "${{github.ref_name}}" == "main" ] || [ "${{github.ref_name}}" == "master" ] || \
( echo "Git ref is neither main nor master, aborting"; exit 1 ) || exit 0
export GIT_SSH_COMMAND='ssh -i ~/.ssh/ssh_key -o IdentitiesOnly=yes'
git clone "ssh://aur@aur.archlinux.org/$pkgbase.git" aur
find aur -maxdepth 1 -type f \
| while read file
do
echo "Removing old file $file ..."
rm -f "$file"
done
git ls-tree --name-only HEAD \
| while read file
do
if [ -f "$file" ]
then
echo "Copying new file $file ..."
cp "$file" aur
fi
done
cd aur
git add .
git config user.name "${{github.event.head_commit.committer.name}}"
git config user.email "${{github.event.head_commit.committer.email}}"
2024-12-09 00:41:40 +01:00
git commit -m "$(echo -e "$pkgbase $pkgver-$pkgrel\n${{github.event.head_commit.url}}")" \
--author "${{github.event.head_commit.author.name}} <${{github.event.head_commit.author.email}}>"
git show HEAD
echo git push aur "${{github.ref_name}}:master"