Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 146da6bcea | |||
| e2d80629f3 | |||
| 3499d1461c | |||
| b6d6e871b0 | |||
| 26ae0ff6fd | |||
| 0b71cf4c42 | |||
| d12efca2e3 | |||
| 28d629073a | |||
| 7229529ad0 | |||
| b9c55b9786 | |||
| 5fdb221abc |
@@ -9,12 +9,10 @@ jobs:
|
||||
lint_n_build:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
- name: Build tarball
|
||||
run: make tarball
|
||||
- name: Build rpm file
|
||||
run: rpmbuild -ba "$(make name).spec"
|
||||
- run: shellcheck files/sbin/gitea_web_notify
|
||||
- run: make tarball
|
||||
- run: rpmbuild -ba "$(make name).spec"
|
||||
|
||||
5
Makefile
5
Makefile
@@ -74,11 +74,12 @@ install: ## Install files into rpm dest (requires env var DESTDIR)
|
||||
printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_TMPPATH)/gitea_images
|
||||
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_TMPPATH)/gitea_images $(DESTDIR)$(RPM_SBINDIR)
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d files/nginx/git.netoik.io.conf
|
||||
install --mode=640 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/gitea files/gitea/app.ini
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR) files/systemd/gitea.service files/systemd/actrunner@.service
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_TMPPATH)/gitea_images files/img/*
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_TMPPATH)/gitea_images files/img/{favicon,logo}.{svg,png}
|
||||
install --mode=755 --target-directory=$(DESTDIR)$(RPM_SBINDIR) files/sbin/gitea_web_notify
|
||||
|
||||
.PHONY: upload
|
||||
upload: ## Upload rpm package to Gitea repository (requires env var PKG_TOKEN)
|
||||
|
||||
12
files/sbin/gitea_web_notify
Normal file
12
files/sbin/gitea_web_notify
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Display commands, exit on error and enable job control
|
||||
set -xem
|
||||
|
||||
gitea web &
|
||||
until curl --fail --head http://localhost:3000
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
systemd-notify --ready
|
||||
fg %1
|
||||
@@ -4,12 +4,14 @@ After=network.target postgresql.service valkey.service
|
||||
|
||||
[Service]
|
||||
RestartSec=2s
|
||||
Type=simple
|
||||
Type=notify
|
||||
User=gitea
|
||||
Group=gitea
|
||||
WorkingDirectory=/var/lib/gitea/
|
||||
ExecStart=/usr/sbin/gitea web
|
||||
Environment=GITEA_WORK_DIR=/var/lib/gitea
|
||||
ExecStart=/usr/sbin/gitea_web_notify
|
||||
Restart=always
|
||||
NotifyAccess=all
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -25,6 +25,13 @@ Install the Git server called Gitea.
|
||||
# Display commands and exit on error
|
||||
set -xe
|
||||
|
||||
# Set environment variables
|
||||
export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
|
||||
export GITEA_BINARY=gitea-1.25.5-linux-$ARCH
|
||||
export GITEA_LUGIT_THEME=gitea-lugit-theme
|
||||
export GITEA_WORK_DIR=/var/lib/gitea
|
||||
export ACTRUNNER_BINARY=act_runner-0.3.0-linux-$ARCH
|
||||
|
||||
# Create gitea user
|
||||
if ! id gitea >/dev/null 2>&1; then
|
||||
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system gitea
|
||||
@@ -32,11 +39,9 @@ fi
|
||||
runuser --user=gitea -- mkdir --parents %{_sharedstatedir}/gitea/{custom,data,log} %{_sharedstatedir}/gitea/custom/conf
|
||||
runuser --user=gitea -- ln --symbolic --force %{_sysconfdir}/gitea/app.ini %{_sharedstatedir}/gitea/custom/conf/app.ini
|
||||
usermod --groups postgres,valkey --append gitea
|
||||
runuser --user=gitea -- printf 'GITEA_WORK_DIR=$HOME\n' >> $HOME/.bash_profile
|
||||
printf 'export GITEA_WORK_DIR=%{_sharedstatedir}/gitea\n' >> %{_sharedstatedir}/gitea/.bash_profile
|
||||
|
||||
# Download and install gitea binary
|
||||
export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
|
||||
export GITEA_BINARY=gitea-1.25.5-linux-$ARCH
|
||||
wget --output-document $GITEA_BINARY https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY
|
||||
wget --output-document $GITEA_BINARY.asc https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
@@ -55,7 +60,6 @@ chmod 640 %{_sysconfdir}/gitea/app.ini
|
||||
chown root:gitea %{_sysconfdir}/gitea/app.ini
|
||||
|
||||
# Add lugit theme
|
||||
export GITEA_LUGIT_THEME=gitea-lugit-theme
|
||||
wget --output-document %{_tmppath}/$GITEA_LUGIT_THEME.tar.gz https://github.com/lucas-labs/gitea-lugit-theme/releases/download/v1.0.1/$GITEA_LUGIT_THEME.tar.gz
|
||||
runuser --user=gitea -- tar --extract --gzip --overwrite --directory=%{_sharedstatedir}/gitea/custom --file %{_tmppath}/$GITEA_LUGIT_THEME.tar.gz
|
||||
rm %{_tmppath}/$GITEA_LUGIT_THEME.tar.gz
|
||||
@@ -67,6 +71,7 @@ if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | gre
|
||||
fi
|
||||
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep --quiet gitea; then
|
||||
runuser --user=postgres -- createdb --owner=gitea gitea
|
||||
runuser --user=gitea -- gitea migrate
|
||||
fi
|
||||
|
||||
# Create admin user
|
||||
@@ -76,7 +81,6 @@ if ! runuser --user=gitea -- gitea admin user list | grep --quiet samuel; then
|
||||
fi
|
||||
|
||||
# Download and install act_runner binary
|
||||
export ACTRUNNER_BINARY=act_runner-0.3.0-linux-$ARCH
|
||||
wget --output-document $ACTRUNNER_BINARY.xz https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz
|
||||
wget --output-document $ACTRUNNER_BINARY.xz.sha256 https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz.sha256
|
||||
cat $ACTRUNNER_BINARY.xz.sha256 | sha256sum --check --status
|
||||
@@ -85,6 +89,11 @@ unxz $ACTRUNNER_BINARY.xz
|
||||
chmod 755 $ACTRUNNER_BINARY
|
||||
mv $ACTRUNNER_BINARY %{_sbindir}/act_runner
|
||||
|
||||
# Restart gitea and nginx services
|
||||
systemctl daemon-reload
|
||||
systemctl reenable gitea.service
|
||||
systemctl restart gitea.service nginx.service
|
||||
|
||||
# Create 4 actrunner users
|
||||
export ACTRUNNER_TOKEN=$(runuser --user=gitea -- gitea actions generate-runner-token)
|
||||
for i in $(seq 1 4); do
|
||||
@@ -92,16 +101,12 @@ for i in $(seq 1 4); do
|
||||
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system actrunner$i
|
||||
fi
|
||||
runuser --user=actrunner$i -- rpmdev-setuptree
|
||||
runuser --user=actrunner$i -- act_runner register --instance https://git.netoik.io --labels self-hosted --name actrunner$i --no-interactive --token $ACTRUNNER_TOKEN
|
||||
printf "runner:\n file: %{_sharedstatedir}/actrunner$i/.runner\n" > %{_sharedstatedir}/actrunner$i/config.yaml
|
||||
runuser --user=actrunner$i -- act_runner --config %{_sharedstatedir}/actrunner$i/config.yaml register --instance http://127.0.0.1:3000 --labels self-hosted --name actrunner$i --no-interactive --token $ACTRUNNER_TOKEN
|
||||
systemctl reenable actrunner@$i.service
|
||||
systemctl restart actrunner@$i.service
|
||||
done
|
||||
|
||||
# Restart gitea and nginx services
|
||||
systemctl daemon-reload
|
||||
systemctl reenable gitea.service
|
||||
systemctl restart gitea.service nginx.service
|
||||
|
||||
%postun
|
||||
# Display commands and exit on error
|
||||
set -xe
|
||||
@@ -144,5 +149,7 @@ fi
|
||||
%dir %attr(755, root, root) %{_tmppath}/gitea_images
|
||||
%attr(644, root, root) %{_tmppath}/gitea_images/{favicon,logo}.{png,svg}
|
||||
|
||||
%attr(755, root, root) %{_sbindir}/gitea_web_notify
|
||||
|
||||
%changelog
|
||||
%autochangelog
|
||||
|
||||
Reference in New Issue
Block a user