-
-
Notifications
You must be signed in to change notification settings - Fork 5
169 lines (143 loc) · 5.55 KB
/
ci.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
# Controls when the workflow will run
on:
schedule:
- cron: '0 0 * * WED'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# This workflow contains a single job called "build"
init:
runs-on: ubuntu-latest
container: ghcr.io/kreatolinux/builder
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Initialize chkupd
id: set-matrix
run: |
rm -rf src
git clone https://github.com/kreatolinux/src
cd src
sed -i s/stable/master/g Makefile
nimble install cligen fuzzy nimcrypto -y
./build.sh -d -p "chkupd"
mv out/chkupd /tmp/
cd ..
rm -rf src
cd /tmp/
./chkupd generateJson --repo="$GITHUB_WORKSPACE" --output="/tmp/out1.json"
echo "matrix=$(cat /tmp/out1.json)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@master
with:
name: chkupd-bin
path: /tmp/chkupd
#- name:
#- name: Check all packages against Arch Repositories
#run: |
#export DOCKER_DEFAULT_PLATFORM=linux/amd64
#cd /tmp/
#./chkupd checkAll --jsonPath=/tmp/chkupd.json --backend="arch" --repo="$GITHUB_WORKSPACE"
#echo "# Arch check results" >> /tmp/chkupd.md
#./out/chkupd jsonToMd /tmp/chkupd.json >> /tmp/chkupd.md
#rm -rf chkupd
#- name: Create Pull Request
#uses: peter-evans/[email protected]
#with:
#commit-message: "[CI] Automated update by chkupd"
build:
needs: init
runs-on: ubuntu-latest
container:
image: ghcr.io/kreatolinux/builder-repo #-gnu # builder-gnu doesn't work yet, see TODO in kpkg/modules/isolation
options: --privileged
strategy:
fail-fast: false
matrix: ${{fromJson(needs.init.outputs.matrix)}}
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: kpkg-amd64-linux-debug
path: /tmp/kpkg-bin
github-token: ${{ secrets.GH_PAT }} # token with actions:read permissions on target repo
repository: kreatolinux/src
run-id: 9630249836 # TODO: Automatically update to latest nightly
- uses: actions/download-artifact@v4
with:
name: chkupd-bin
path: /tmp/chkupd
- uses: actions/checkout@v4
- name: Build packages
run: |
. /etc/profile
chmod +x /tmp/chkupd/chkupd
chmod +x /tmp/kpkg-bin/kpkg
mkdir -p /etc/kpkg/repos/main
mount --bind "$GITHUB_WORKSPACE" /etc/kpkg/repos/main
for package in ${{ matrix.packages }}; do
grep "NO_CHKUPD=" "$GITHUB_WORKSPACE/$package/run" > /tmp/sourced_chkupd || NO_CHKUPD=false
. /tmp/sourced_chkupd
case $NO_CHKUPD in
"y" | "yes" | "true" | "1" | "on")
echo "no_chkupd enabled on $package"
echo "skipping autoupdate"
;;
*)
/tmp/chkupd/chkupd repologyCheck --package="$package" --repo="$GITHUB_WORKSPACE" --autoUpdate=true
;;
esac
unset NO_CHKUPD
rm -f /tmp/sourced_chkupd
done
/tmp/kpkg-bin/kpkg clean --binaries=true
IS_USELESS="true"
for package in ${{ matrix.packages }}; do
/tmp/kpkg-bin/kpkg install "$package" -y || IS_USELESS="false"
done
git config --system --add safe.directory '*'
if [ "$IS_USELESS" = "true" ]; then
mkdir -p /var/cache/kpkg/archives
touch /var/cache/kpkg/archives/IS_USELESS
exit 0
fi
/tmp/kpkg-bin/kpkg build ${{ matrix.packages }} --yes --ignorePostInstall #--forceInstallAll=true --yes
#echo RANDOM_ID=$(cat /dev/urandom | tr -dc '[:alpha:]' | fold -w ${1:-20} | head -n 1) >> $GITHUB_ENV
cd "$GITHUB_WORKSPACE"
git pull
git status
- name: Install Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
version: 1.70.0
- name: Upload to server through rsync
env:
KNOWN_HOSTS: ${{ secrets.KNOWN_HOSTS }}
SSH_URL: ${{ secrets.SSH_URL }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
RSYNC_RSH: "ssh -o StrictHostKeychecking=no"
run: |
if [ -f "/var/cache/kpkg/archives/IS_USELESS" ]; then
exit 0
fi
mkdir -p ~/.ssh
eval $(ssh-agent)
echo "$SSH_KEY" | ssh-add -
echo "$KNOWN_HOSTS" >> /tmp/known_hosts
rsync -avc /var/cache/kpkg/archives/ $SSH_USER@$SSH_URL:/var/cache/kpkg/archives/
rsync -avc /var/cache/kpkg/sources/ $SSH_USER@$SSH_URL:/var/cache/kpkg/sources/
#- uses: actions/upload-artifact@v4
# with:
# name: packages-${{ env.RANDOM_ID }}
# path: /var/cache/kpkg/archives/arch
# retention-days: 2
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply auto-update through chkupd