-
Notifications
You must be signed in to change notification settings - Fork 229
94 lines (81 loc) · 2.79 KB
/
Copy pathmirrors.yml
File metadata and controls
94 lines (81 loc) · 2.79 KB
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
name: Mirrors
on:
push:
branches:
- master
paths:
- 'mirrors/**'
- 'wiki/mirrors_header.md'
pull_request:
paths:
- 'mirrors/**'
jobs:
lint-mirror-files:
runs-on: ubuntu-slim
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Check mirror files
run: |
for file in mirrors/default $(git ls-files mirrors/*/*); do
if head -n 4 "$file" | grep -qv '^#'; then
echo "Error: $file does not have 4 header lines starting with #" > /dev/stderr
exit 1
fi
if ! grep -q '^MAIN=' "$file"; then
echo "Error: $file does not contain MAIN" > /dev/stderr
exit 1
fi
if ! grep -q '^ROOT=' "$file"; then
echo "Error: $file does not contain ROOT" > /dev/stderr
exit 1
fi
if ! grep -q '^X11=' "$file"; then
echo "Error: $file does not contain X11" > /dev/stderr
exit 1
fi
if ! grep -q "$(basename $file)" mirrors/Makefile.am; then
echo "Error: $file is not listed in mirrors/Makefile.am"
fi
echo "$file passed validation."
done
update-wiki-mirror:
runs-on: ubuntu-slim
needs: lint-mirror-files
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up SSH key
env:
GITHUB_SSH_KEY: ${{ secrets.TERMUXBOT2_SSH_KEY }}
run: |
mkdir -p ~/.ssh
echo "$GITHUB_SSH_KEY" > ~/.ssh/id_ed25519_termuxbot2
chmod 600 ~/.ssh/id_ed25519_termuxbot2
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Clone termux-packages.wiki
run: |
if [ ! -d termux-packages.wiki ]; then
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_termuxbot2" git clone git@github.com:termux/termux-packages.wiki.git
cd termux-packages.wiki
else
cd termux-packages.wiki
git pull origin master
fi
git config --global user.name "Termux Github Actions"
git config --global user.email "contact@termux.dev"
- name: Generate the Wiki page
run: |
cd termux-packages.wiki
bash ../mirrors/generate-wiki-page.sh
- name: Commit and push changes
run: |
cd termux-packages.wiki
git add Mirrors.md
# Check if there are any changes before commiting and pushing
if ! git diff --cached --exit-code > /dev/null; then
git commit -m "Update Mirrors.md after termux-tools commit ${GITHUB_SHA::12}" \
-m "See https://github.com/termux/termux-tools/tree/${GITHUB_SHA}."
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_termuxbot2" git push origin master
fi