Compare commits

...

5 Commits

Author SHA1 Message Date
b1688d45a8 [*] 修改为 group
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 9s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 18m11s
2025-01-13 20:08:43 +08:00
5c7ccf4f4f 修改 ubuntu debian 源 2025-01-13 20:07:25 +08:00
28a83e30f5 [*] 修改判断条件
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 38s
2025-01-05 23:55:09 +08:00
1d36cdba41 [*] 兼容action测试
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 5m59s
2025-01-05 23:45:23 +08:00
33b6b3013a [+] 添加 action 测试
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2m31s
2025-01-05 23:35:53 +08:00
4 changed files with 70 additions and 26 deletions

View File

@ -0,0 +1,12 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- name: test apt
run: curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
- name: test docker
run: curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-docker.sh | bash

View File

@ -25,17 +25,32 @@ pip config set global.index-url https://mirrors.martin98.com/repository/pypi-gro
npm config set registry https://mirrors.martin98.com/repository/npm-group/ npm config set registry https://mirrors.martin98.com/repository/npm-group/
``` ```
##### docker 容器中 #### dockerfile
##### DEB822 格式
```bash ```bash
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \ --mount=type=cache,target=/var/lib/apt \
sed -i '6,$d' /etc/apt/sources.list.d/dhttps://mirrors.mebian.sources && \ APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" \
sed -i 's|http://deb.debian.org/debian|artin98.com/repository/debian-tsinghua/|g' /etc/apt/sources.list.d/debian.sources && \ type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) && \
apt update && \ sed -i '6,$d' /etc/apt/sources.list.d/${type}.sources && \
apt install -y --no-install-recommends \ sed -i "s|http://deb.debian.org/debian|https://mirrors.martin98.com/repository/${type}-tsinghua/|g" /etc/apt/sources.list.d/${type}.sources && \
gcc \ apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates curl && update-ca-certificates
g++ \ ```
python3-dev ##### 传统格式
```bash
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" \
type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) && \
release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) && \
components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse")) && \
echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${release}${suite#noble}/ ${suite} ${components}"
echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${release}/ ${suite} ${components}"
sed -i '6,$d' /etc/apt/sources.list.d/${type}.sources && \
sed -i "s|http://deb.debian.org/debian|https://mirrors.martin98.com/repository/${type}-tsinghua/|g" /etc/apt/sources.list.d/${type}.sources && \
apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates && update-ca-certificates
``` ```
#### 进入容器 #### 进入容器

View File

@ -1,22 +1,30 @@
#!/bin/bash #!/bin/bash
# 配置 ubuntu 源 type=$(cat /etc/*release | grep ^ID= | cut -d= -f2)
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2)
cat > /etc/apt/sources.list.d/ubuntu.sources <<EOF components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse"))
Types: deb
URIs: https://mirrors.martin98.com/repository/ubuntu-tsinghua/ # DEB822 格式
Suites: noble noble-updates noble-backports # docker.martin98.com/library/ubuntu:latest
Components: main restricted universe multiverse # docker.martin98.com/library/debian:latest
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg if [ -f /etc/apt/sources.list.d/${type}.sources ]; then
cat > /etc/apt/sources.list.d/${type}.sources <<EOF
$(for suite in ${release} ${release}-updates ${release}-backports; do
echo "Types: deb"
echo "URIs: https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/"
echo "Suites: $suite"
echo "Components: ${components}"
echo "Signed-By: /usr/share/keyrings/${type}-archive-keyring.gpg"
echo
done)
EOF EOF
# 配置 debian 源 # 传统格式
elif [ -f /etc/apt/sources.list.d/debian.sources ]; then # docker.martin98.com/library/ubuntu:22.04
cat > /etc/apt/sources.list.d/debian.sources <<EOF elif [ -f /etc/apt/sources.list ]; then
Types: deb cat > /etc/apt/sources.list <<EOF
URIs: https://mirrors.martin98.com/repository/debian-tsinghua/ $(for suite in ${release} ${release}-updates ${release}-backports; do
Suites: bookworm bookworm-updates bookworm-backports echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/ ${suite} ${components}"
Components: main contrib non-free non-free-firmware done)
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF EOF
else else
echo "没有找到合适的源" echo "没有找到合适的源"
@ -38,7 +46,12 @@ server ntp5.aliyun.com iburst
driftfile /var/lib/chrony/drift driftfile /var/lib/chrony/drift
allow 127.0.0.1 allow 127.0.0.1
EOF EOF
systemctl restart chrony && systemctl enable chrony
if pidof systemd >/dev/null 2>&1; then
systemctl restart chrony && systemctl enable chrony
else
echo "systemctl 不存在,跳过 chrony 的重启"
fi
# fix vim 粘贴 # fix vim 粘贴
if ! grep -q "set pastetoggle=" ~/.vimrc; then if ! grep -q "set pastetoggle=" ~/.vimrc; then

View File

@ -21,4 +21,8 @@ cat > /etc/docker/daemon.json <<EOF
} }
EOF EOF
sudo systemctl restart docker if pidof systemd >/dev/null 2>&1; then
systemctl restart docker
else
echo "systemctl 不存在,跳过 docker 重启。"
fi