-
Notifications
You must be signed in to change notification settings - Fork 3
95 lines (78 loc) · 2.88 KB
/
aur.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Update AUR
on:
push:
branches:
- master # monitor changes only in the master branch
paths:
- PKGBUILD # monitor changes to the PKGBUILD file
workflow_dispatch: # allow manually triggering the workflow
env:
REMOTE_HOST: aur.archlinux.org
REMOTE_HOST_USER: aur
REMOTE_HOST_PREFIX: ssh
REMOTE_REPO_NAMESPACE: ''
REMOTE_REPO_NAME: kf6-service-menu-reimage
REMOTE_REPO_USER: irfanhakim
REMOTE_REPO_EMAIL: [email protected]
jobs:
update-aur:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
id: checkout
uses: actions/checkout@v3
- name: Set up SSH
id: configure_ssh
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.AUR_PRIVATE_KEY }}
- name: Add remote host to known hosts
id: add_remote_host
run: |
ssh-keyscan ${REMOTE_HOST} >> ~/.ssh/known_hosts
- name: Clone the remote repository
id: clone_remote_repo
run: |
# set variables
REMOTE_HOST_PREFIX="${{ env.REMOTE_HOST_PREFIX }}${{ env.REMOTE_HOST_PREFIX && '://' }}"
REMOTE_REPO_NAMESPACE="${{ env.REMOTE_REPO_NAMESPACE && ':' }}${{ env.REMOTE_REPO_NAMESPACE }}"
# clone remote repository
git clone ${REMOTE_HOST_PREFIX}${REMOTE_HOST_USER:-git}@${REMOTE_HOST}${REMOTE_REPO_NAMESPACE}/${REMOTE_REPO_NAME}.git
- name: Copy package files to remote repository
id: copy_pkgfiles
run: |
cp .SRCINFO PKGBUILD ${REMOTE_REPO_NAME}/
- name: Check if package files have changes
id: check_changes
run: |
# change working directory
cd ${REMOTE_REPO_NAME}
# add package files
git add .SRCINFO PKGBUILD
# check for changes
if git diff --cached --exit-code >/dev/null; then
echo "No changes have been made to the package files."
exists=false
else
echo "Package files have been updated and are pending commit."
exists=true
fi
# export result to output
echo "exists=${exists}" | tee -a ${GITHUB_OUTPUT}
- name: Commit and push updated package files
id: push_changes
if: steps.check_changes.outputs.exists == 'true'
run: |
# set variables
source PKGBUILD
version="${pkgver}"
release="${pkgrel}"
# change working directory
cd ${REMOTE_REPO_NAME}
# configure git
git config --local user.name "${REMOTE_REPO_USER:-github-actions[bot]}"
git config --local user.email "${REMOTE_REPO_EMAIL:-github-actions[bot]@users.noreply.github.com}"
# commit changes
git commit -m "Update to ${version}-${pkgrel}"
# push commit
git push -u origin HEAD