Skip to content

Commit b7abfcf

Browse files
committed
test
1 parent 072fee4 commit b7abfcf

File tree

2 files changed

+314
-0
lines changed

2 files changed

+314
-0
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: 🐬 Push Bootstrap Images (x86_64) 🐬
2+
concurrency:
3+
group: "${{ github.workflow }}-${{ github.ref }}"
4+
cancel-in-progress: true
5+
6+
on:
7+
workflow_dispatch:
8+
schedule:
9+
- cron: "0 0 */3 * *" #every 3 Days @5:45 AM NPT
10+
jobs:
11+
push-x86_64:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 200
14+
permissions:
15+
attestations: write
16+
contents: write
17+
id-token: write
18+
packages: write
19+
statuses: read
20+
strategy:
21+
matrix:
22+
include:
23+
#- image: "archlinux-base"
24+
# script: "${GITHUB_WORKSPACE}/main/Github/Runners/bootstrap/archlinux.sh"
25+
# arch: "x86_64"
26+
# file: "/tmp/archlinux.tar"
27+
28+
- image: "cachyos-base"
29+
script: "${GITHUB_WORKSPACE}/main/Github/Runners/bootstrap/cachyos.sh"
30+
arch: "x86_64"
31+
file: "/tmp/cachyos-base.tar"
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
with:
36+
path: main
37+
filter: "blob:none"
38+
39+
- name: Debloat Runner
40+
run: |
41+
#Presets
42+
set +x ; set +e
43+
#--------------#
44+
bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Github/Runners/debloat_ubuntu.sh")
45+
continue-on-error: true
46+
47+
- name: Set up QEMU
48+
uses: docker/setup-qemu-action@v3
49+
continue-on-error: true
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
continue-on-error: true
54+
55+
- name: Login to Docker Hub
56+
uses: docker/login-action@v3
57+
with:
58+
username: "${{ secrets.DOCKERHUB_USERNAME }}"
59+
password: "${{ secrets.DOCKERHUB_TOKEN }}"
60+
continue-on-error: true
61+
62+
- name: Login to GHCR
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ghcr.io
66+
username: "${{ github.actor }}"
67+
password: "${{ secrets.GITHUB_TOKEN }}"
68+
continue-on-error: true
69+
70+
- name: Install Addons
71+
run: |
72+
#presets
73+
set +x ; set +e
74+
#-------------#
75+
bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh")
76+
continue-on-error: true
77+
78+
- name: Setup Env
79+
run: |
80+
#presets
81+
set +x ; set +e
82+
#-------------#
83+
#tmp
84+
SYSTMP="$(dirname $(mktemp -u))" && export SYSTMP="${SYSTMP}"
85+
echo "SYSTMP=${SYSTMP}" >> "${GITHUB_ENV}"
86+
#-------------#
87+
##User-Agent
88+
USER_AGENT="$(curl -qfsSL 'https://pub.ajam.dev/repos/Azathothas/Wordlists/Misc/User-Agents/ua_chrome_macos_latest.txt')" && export USER_AGENT="${USER_AGENT}"
89+
echo "USER_AGENT=${USER_AGENT}" >> "${GITHUB_ENV}"
90+
continue-on-error: true
91+
92+
- name: Push (${{ matrix.image }}/${{ matrix.arch }})
93+
env:
94+
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}"
95+
run: |
96+
#presets
97+
set +x ; set +e
98+
#-------------#
99+
dos2unix --quiet "${{ matrix.script }}"
100+
chmod +x "${{ matrix.script }}"
101+
bash "${{ matrix.script }}"
102+
continue-on-error: true
103+
104+
- name: Check
105+
run: |
106+
#presets
107+
set +x ; set +e
108+
#-------------#
109+
if [[ -s "${{ matrix.file }}" ]] && [[ $(stat -c%s "${{ matrix.file }}") -gt 10000 ]]; then
110+
export HAS_IMAGE="TRUE"
111+
echo "HAS_IMAGE=${HAS_IMAGE}" >> "${GITHUB_ENV}"
112+
UTC_TIME="$(TZ='UTC' date +'%Y_%m_%d')"
113+
echo "UTC_TIME=${UTC_TIME}" >> "${GITHUB_ENV}"
114+
else
115+
export HAS_IMAGE="FALSE"
116+
echo "HAS_IMAGE=${HAS_IMAGE}" >> "${GITHUB_ENV}"
117+
fi
118+
continue-on-error: true
119+
120+
- name: Fail (If Push Failed)
121+
if: env.HAS_IMAGE == 'FALSE'
122+
run: |
123+
#presets
124+
set +x ; set +e
125+
#-------------#
126+
exit 1
127+
continue-on-error: false
128+
129+
#Artifacts
130+
- name: Upload (Build) Artifacts
131+
if: env.HAS_IMAGE == 'TRUE'
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: ARTIFACTS
135+
path: |
136+
"${{ matrix.file }}"
137+
compression-level: 0 #no compression, [Default: 6 (GNU Gzip)]
138+
retention-days: 90 #max
139+
overwrite: true
140+
continue-on-error: true
141+
142+
#continuous
143+
- name: Releaser (Continuous)
144+
if: env.HAS_IMAGE == 'TRUE'
145+
uses: softprops/[email protected]
146+
with:
147+
name: "Continuous ${{ matrix.image }}_${{ matrix.arch }}"
148+
tag_name: "${{ matrix.image }}_${{ matrix.arch }}"
149+
prerelease: true
150+
draft: false
151+
generate_release_notes: false
152+
files: |
153+
"${{ matrix.file }}"
154+
continue-on-error: true
155+
156+
#Snapshot
157+
- name: Releaser (Snapshot)
158+
if: env.HAS_IMAGE == 'TRUE'
159+
uses: softprops/[email protected]
160+
with:
161+
name: "Snapshot-(${{ matrix.image }}_${{ matrix.arch }}_${{ env.UTC_TIME }}"
162+
tag_name: "${{ matrix.image }}_${{ matrix.arch }}_${{ env.UTC_TIME }}"
163+
prerelease: false
164+
draft: false
165+
generate_release_notes: false
166+
make_latest: false
167+
files: |
168+
"${{ matrix.file }}"
169+
continue-on-error: true
170+
171+
#Build Provenance
172+
- name: Attest Build Provenance
173+
if: env.HAS_IMAGE == 'TRUE'
174+
uses: actions/[email protected]
175+
with:
176+
subject-name: "image-${{ matrix.image }}-${{ matrix.arch }}"
177+
subject-path: "${{ matrix.file }}"
178+
show-summary: true
179+
continue-on-error: true
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/bin/env bash
2+
#
3+
##DO NOT RUN DIRECTLY
4+
##Self: bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Github/Runners/bootstrap/cachyos.sh")
5+
#-------------------------------------------------------#
6+
7+
#-------------------------------------------------------#
8+
set -x
9+
## No aarch64 docker yet: https://hub.docker.com/r/cachyos/cachyos/tags
10+
## Official Response: https://discuss.cachyos.org/t/arm-future-for-cachyos/727/2
11+
## https://github.com/CachyOS/docker
12+
if [ "$(uname -m)" == "aarch64" ]; then
13+
exit 0
14+
fi
15+
#-------------------------------------------------------#
16+
17+
#-------------------------------------------------------#
18+
##Bootstrap
19+
pushd "$(mktemp -d)" >/dev/null 2>&1
20+
docker stop "cachyos-base" 2>/dev/null ; docker rm "cachyos-base" 2>/dev/null
21+
docker run --name "cachyos-base" --privileged "cachyos/cachyos-v3:latest" bash -l -c '
22+
#Bootstrap
23+
pacman -y --sync --refresh --refresh --sysupgrade --noconfirm --debug
24+
packages="bash binutils curl fakechroot fakeroot git wget"
25+
for pkg in $packages; do pacman -Sy "$pkg" --noconfirm ; done
26+
for pkg in $packages; do pacman -Sy "$pkg" --needed --noconfirm ; done
27+
#Fix & Patches
28+
sed '\''/DownloadUser/d'\'' -i "/etc/pacman.conf"
29+
#sed '\''s/^.*Architecture\s*=.*$/Architecture = auto/'\'' -i "/etc/pacman.conf"
30+
sed '\''0,/^.*SigLevel\s*=.*/s//SigLevel = Never/'\'' -i "/etc/pacman.conf"
31+
#sed '\''s/^.*SigLevel\s*=.*$/SigLevel = Never/'\'' -i "/etc/pacman.conf"
32+
sed '\''/#\[multilib\]/,/#Include = .*/s/^#//'\'' -i "/etc/pacman.conf"
33+
echo -e "nameserver 8.8.8.8\nnameserver 2620:0:ccc::2" | tee "/etc/resolv.conf"
34+
echo -e "nameserver 1.1.1.1\nnameserver 2606:4700:4700::1111" | tee -a "/etc/resolv.conf"
35+
unlink "/var/lib/dbus/machine-id" 2>/dev/null
36+
unlink "/etc/machine-id" 2>/dev/null
37+
rm -rvf "/etc/machine-id"
38+
systemd-machine-id-setup --print 2>/dev/null | tee "/var/lib/dbus/machine-id"
39+
cat "/var/lib/dbus/machine-id" | tee "/etc/machine-id"
40+
pacman -Scc --noconfirm
41+
echo "disable-scdaemon" | tee "/etc/pacman.d/gnupg/gpg-agent.conf"
42+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/flatimage-base/refs/heads/main/archlinux_hooks.sh" -o "/arch_hooks.sh"
43+
chmod +x "/arch_hooks.sh" ; "/arch_hooks.sh"
44+
rm -rfv "/arch_hooks.sh"
45+
echo "LANG=en_US.UTF-8" | tee "/etc/locale.conf"
46+
echo "LANG=en_US.UTF-8" | tee -a "/etc/locale.conf"
47+
echo "LANGUAGE=en_US:en" | tee -a "/etc/locale.conf"
48+
echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/locale.conf"
49+
echo "en_US.UTF-8 UTF-8" | tee -a "/etc/locale.gen"
50+
echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/environment"
51+
locale-gen ; locale-gen "en_US.UTF-8"
52+
#Cleanup
53+
pacman -y --sync --refresh --refresh --sysupgrade --noconfirm
54+
pacman -Rsn base-devel --noconfirm
55+
pacman -Rsn perl --noconfirm
56+
pacman -Rsn python --noconfirm
57+
pacman -Scc --noconfirm
58+
#Fake-Sudo
59+
pacman -Rsndd sudo 2>/dev/null
60+
rm -rvf "/usr/bin/sudo" 2>/dev/null
61+
curl -qfsSL "https://github.com/pkgforge/flatimage-base/releases/download/$(uname -m)/fake-sudo-pkexec.tar.zst" -o "./fake-sudo-pkexec.tar.zst" && chmod +x "./fake-sudo-pkexec.tar.zst"
62+
pacman -Uddd "./fake-sudo-pkexec.tar.zst" --noconfirm
63+
pacman -Syy fakeroot --needed --noconfirm
64+
rm -rvf "./fake-sudo-pkexec.tar.zst"
65+
#Yay
66+
curl -qfsSL "https://github.com/pkgforge/flatimage-base/releases/download/$(uname -m)/yay" -o "/usr/bin/yay" && chmod +x "/usr/bin/yay"
67+
yay --version ; which fakeroot yay sudo
68+
#More cleanup
69+
rm -rfv "/usr/share/gtk-doc/"* 2>/dev/null
70+
rm -rfv "/usr/share/man/"* 2>/dev/null
71+
rm -rfv "/usr/share/help/"* 2>/dev/null
72+
rm -rfv "/usr/share/info/"* 2>/dev/null
73+
rm -rfv "/usr/share/doc/"* 2>/dev/null
74+
rm -rfv "/var/tmp/"* 2>/dev/null
75+
rm -rfv "/var/lib/pacman/sync/"* 2>/dev/null
76+
rm -rfv "/var/cache/pacman/pkg/"* 2>/dev/null
77+
find "/boot" -mindepth 1 -delete 2>/dev/null
78+
find "/dev" -mindepth 1 -delete 2>/dev/null
79+
find "/proc" -mindepth 1 -delete 2>/dev/null
80+
find "/run" -mindepth 1 -delete 2>/dev/null
81+
find "/sys" -mindepth 1 -delete 2>/dev/null
82+
find "/tmp" -mindepth 1 -delete 2>/dev/null
83+
find "/usr/include" -mindepth 1 -delete 2>/dev/null
84+
find "/usr/lib" -type f -name "*.a" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
85+
find "/usr/lib32" -type f -name "*.a" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
86+
find "/etc/pacman.d/gnupg" -type f -name "S.*" -print -exec rm -rfv "{}" 2>/dev/null \; 2>/dev/null
87+
find "/usr/share/locale" -mindepth 1 -maxdepth 1 ! -regex ".*/\(locale.alias\|en\|en_US\)$" -exec rm -rfv "{}" + 2>/dev/null
88+
find "/usr/share/doc" -mindepth 1 -delete 2>/dev/null
89+
find "/usr/share/gtk-doc" -mindepth 1 -delete 2>/dev/null
90+
find "/usr/share/help" -mindepth 1 -delete 2>/dev/null
91+
find "/usr/share/info" -mindepth 1 -delete 2>/dev/null
92+
find "/usr/share/man" -mindepth 1 -delete 2>/dev/null
93+
find "." -type d -name "__pycache__" -exec rm -rfv "{}" \; 2>/dev/null
94+
find "." -type f -name "*.pacnew" -exec rm -rfv "{}" \; 2>/dev/null
95+
find "." -type f -name "*.pacsave" -exec rm -rfv "{}" \; 2>/dev/null
96+
find "/var/log" -type f -name "*.log" -exec rm -rfv "{}" \; 2>/dev/null
97+
rm -rfv "/"{tmp,proc,sys,dev,run} 2>/dev/null
98+
mkdir -pv "/"{tmp,proc,sys,dev,run/media,mnt,media,home} 2>/dev/null
99+
rm -fv ""/etc/{host.conf,hosts,nsswitch.conf} 2>/dev/null
100+
touch ""/etc/{host.conf,hosts,nsswitch.conf} 2>/dev/null
101+
hostname 2>/dev/null; cat "/etc/os-release" 2>/dev/null'
102+
##Export
103+
docker export "$(docker ps -aqf 'name=cachyos')" --output "rootfs.tar"
104+
if [[ -f "./rootfs.tar" ]] && [[ $(stat -c%s "./rootfs.tar") -gt 10000 ]]; then
105+
mkdir -pv "./rootfs" && export ROOTFS_DIR="$(realpath "./rootfs")"
106+
rsync -achLv --mkpath "./rootfs.tar" "/tmp/cachyos-base.tar"
107+
else
108+
echo "\n[-] FATAL: Failed to export ROOTFS\n"
109+
exit 1
110+
fi
111+
popd "$(mktemp -d)" >/dev/null 2>&1
112+
#-------------------------------------------------------#
113+
114+
115+
#-------------------------------------------------------#
116+
##Push
117+
#ENV
118+
D_ID="$(docker ps -qf 'name=cachyos-base' | tr -d '[:space:]')"
119+
D_TAG="v$(date +'%Y.%m.%d' | tr -d '[:space:]')"
120+
export D_ID D_TAG
121+
#Tags
122+
docker commit "${D_ID}" "pkgforge/cachyos-base:latest"
123+
docker commit "${D_ID}" "ghcr.io/pkgforge/devscripts/cachyos-base:latest"
124+
docker commit "${D_ID}" "pkgforge/cachyos-base:${DOCKER_TAG}"
125+
docker commit "${D_ID}" "ghcr.io/pkgforge/devscripts/cachyos-base:${DOCKER_TAG}"
126+
docker commit "${D_ID}" "pkgforge/cachyos-base:$(uname -m)"
127+
docker commit "${D_ID}" "ghcr.io/pkgforge/devscripts/cachyos-base:$(uname -m)"
128+
#Push
129+
docker push "pkgforge/cachyos-base:latest"
130+
docker push "ghcr.io/pkgforge/devscripts/cachyos-base:latest"
131+
docker push "pkgforge/cachyos-base:${DOCKER_TAG}"
132+
docker push "ghcr.io/pkgforge/devscripts/cachyos-base:${DOCKER_TAG}"
133+
docker push "pkgforge/cachyos-base:$(uname -m)"
134+
docker push "ghcr.io/pkgforge/devscripts/cachyos-base:$(uname -m)"
135+
#-------------------------------------------------------#

0 commit comments

Comments
 (0)