summaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/aur.yml
blob: ae85941f3d04242e2c9c5afd8addb45aa4fb13c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Publish to AUR

on:
  workflow_call:
  workflow_dispatch:

jobs:
  publish:
    name: Publish to AUR
    runs-on: ubuntu-latest
    container:
      image: archlinux:base-devel
    steps:
      # This step must be done before actions/checkout. From the latter's
      # output:
      #
      #     To create a local Git repository instead, add Git 2.18 or higher to the PATH
      #
      - name: Install dependencies
        run: |
          pacman -Syu --noconfirm git openssh

      - name: Checkout
        uses: actions/checkout@v7
        with:
          ref: aur
          token: '${{ secrets.GH_TOKEN }}'

      # makepkg for no reason hard-forbids running as root. Kill me now.
      - name: Add builder user
        run: |
          useradd -m -s /bin/bash builder
          passwd -d builder
          echo 'builder ALL=(ALL) ALL' >> /etc/sudoers
          chown -R builder:builder -- "$GITHUB_WORKSPACE"

      - name: Configure SSH
        run: |
          mkdir -p /home/builder/.ssh/
          cat > /home/builder/.ssh/config <<'EOF'
          StrictHostKeyChecking no
          EOF
          cat > /home/builder/.ssh/id_ed25519 <<'EOF'
          ${{ secrets.SSH_KEY }}
          EOF
          chown -R builder:builder /home/builder/.ssh
          chmod 0600 /home/builder/.ssh/id_ed25519

      - name: Configure git
        run: |
          # See https://github.com/actions/checkout#push-a-commit-using-the-built-in-token
          runuser -u builder -- git -C "$GITHUB_WORKSPACE" config user.name "github-actions[bot]"
          runuser -u builder -- git -C "$GITHUB_WORKSPACE" config user.email "41898282+github-actions[bot]@users.noreply.github.com"

      - name: Run maintenance
        run: |
          runuser -u builder -- make -C "$GITHUB_WORKSPACE" maintenance