commit dd59a3024be94707eda4350aef7330bfc127b8fa Author: Dominic Date: Sat Mar 25 13:25:57 2023 +0100 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..cef0906 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Test and Mirror AUR Packages + +This action tests that building a package succeeds and then mirrors any changes to the AUR. + +## Example + +```yaml +jobs: + mirror: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: https://msrd0.dev/aur/.mirror@main + with: + ssh_key: ${{secrets.ssh_key}} +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..91295e8 --- /dev/null +++ b/action.yml @@ -0,0 +1,46 @@ +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: + - name: Pull up2date ArchLinux image + run: docker pull docker.io/library/archlinux:base-devel + + - name: Test AUR package + uses: docker://docker.io/library/archlinux:base-devel + with: + entrypoint: makepkg + args: -s + + - name: Ensure .SRCINFO is up to date + uses: docker://docker.io/library/archlinux:base-devel + with: + entrypoint: bash + args: -c 'makepkg --printsrcinfo >>.SRCINFO.new && diff -u .SRCINFO{,.new}' + + - name: Mirror to the AUR + run: | + printf '%s' '${{inputs.ssh_key}}' >ssh_key + echo 'aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN' >>~/.ssh/known_hosts + + pkgbase='${{inputs.pkgbase}}' + [ -n "$pkgbase" ] || pkgbase="$( (. PKGBUILD && printf '%s' "$pkgbase") )" + [ -n "$pkgbase" ] || pkgbase="$( (. PKGBUILD && printf '%s' "$pkgname") )" + + [ -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_key -o IdentitiesOnly=yes' + git remote add aur "ssh://aur@aur.archlinux.org/$pkgbase.git" + git push aur "${{github.ref_name}}:master"