forked from talesam/build-iso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
269 lines (227 loc) · 8.61 KB
/
action.yml
File metadata and controls
269 lines (227 loc) · 8.61 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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# -*- coding: utf-8 -*-
#
# action.yml
name: "Build ISO"
description: "Builds a Custom ISO image for BigCommunity/BigLinux"
inputs:
distroname:
description: "Distribution name"
required: true
iso_profiles_repo:
description: "ISO profiles repository URL"
required: true
edition:
description: "ISO profile edition"
required: true
community_branch:
description: "Community branch"
required: false
biglinux_branch:
description: "BigLinux branch"
required: true
manjaro_branch:
description: "Manjaro branch"
required: false
default: "stable"
kernel:
description: "Kernel version"
required: true
release_tag:
description: "Release tag"
required: true
tmate:
description: "Enable tmate debugging"
required: false
default: false
github_token:
description: "GitHub token"
required: true
outputs:
iso_path:
description: "Path to the generated ISO file"
value: ${{ steps.build.outputs.iso_path }}
release_name:
description: "Name of the release"
value: ${{ steps.prepare-iso.outputs.release_name }}
runs:
using: "composite"
steps:
- name: Define terminal utility functions
shell: bash
run: |
cat << 'EOF' > /tmp/terminal_utils.sh
export TERM=${TERM:-xterm-256color}
# Color definitions
blueDark="\e[1;38;5;33m"
lightBlue="\e[1;38;5;39m"
cyan="\e[1;38;5;45m"
white="\e[1;97m"
reset="\e[0m"
red="\e[1;31m"
green="\e[1;32m"
die() {
local msg="$(sed 's/<[^>]*>//g' <<< "$1")"
echo -e "BP=>${red}error: ${white}${msg}${reset}"
exit 1
}
export -f die
msg() {
local msg="$(sed 's/<[^>]*>//g' <<< "$1")"
echo -e "BP=>${blueDark}[${lightBlue}RUNNING${blueDark}]${reset} ${cyan}→${reset} ${white}${msg}${reset}"
}
export -f msg
msg_ok() {
local msg="$(sed 's/<[^>]*>//g' <<< "$1")"
echo -e "BP=>${blueDark}[${green}SUCCESS${blueDark}]${reset} ${cyan}→${reset} ${white}${msg}${reset}"
}
export -f msg_ok
msg_info() {
local msg="$(sed 's/<[^>]*>//g' <<< "$1")"
echo -e "BP=>${blueDark}[${cyan}INFO${blueDark}]${reset} ${cyan}→${reset} ${white}${msg}${reset}"
}
export -f msg_info
msg_run() {
echo -e "BP=>${blueDark}[${lightBlue}COMMAND${blueDark}]${reset} ${cyan}→${reset} ${white}$1${reset}"
eval "$1"
}
export -f msg_run
replicate() {
local char=${1:-'#'}
local nsize=${2:-$(tput cols)}
local line
printf -v line "%*s" "$nsize" && echo -e "${blueDark}${line// /$char}${reset}"
}
export -f replicate
send_telegram_message() {
local message="$1"
echo -e "${red}ERROR: $(sed 's/<[^>]*>//g' <<< "$message")${reset}"
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
-d chat_id="${CHAT_ID}" \
-d text="${message}" \
-d parse_mode="HTML"
}
export -f send_telegram_message
EOF
- name: Display system information
shell: bash
run: |
source /tmp/terminal_utils.sh
replicate '='
msg_info "Current host: $(hostname)"
msg_info "Current user: $(whoami) [$(id -u)]"
msg_info "User details: $(id)"
replicate '='
msg_run "df -hT || true"
replicate '='
msg_run "ls -la /mnt || true"
replicate '='
- name: Setup build environment
shell: bash
run: |
source /tmp/terminal_utils.sh
# Setup build environment
msg "Setting up build packages"
# Add community repository if needed
if [[ "${{ inputs.distroname }}" == 'bigcommunity' ]]; then
msg_info "Adding community-extra repository"
{
echo "[community-extra]"
echo "SigLevel = PackageRequired"
echo "Server = https://repo.communitybig.org/extra/\$arch"
echo
} | sudo tee -a /etc/pacman.conf > /dev/null
fi
# Setup cryptographic keys
msg "Setting up cryptographic keys"
git clone https://github.com/biglinux/biglinux-key.git
sudo install -dm755 /etc/pacman.d/gnupg/
sudo install -m0644 biglinux-key/usr/share/pacman/keyrings/* /etc/pacman.d/gnupg/
sudo rm -r biglinux-key
if [[ "${{ inputs.distroname }}" == 'bigcommunity' ]]; then
git clone https://github.com/big-comm/community-keyring.git
sudo install -m0644 community-keyring/community.gpg /usr/share/pacman/keyrings/
sudo install -m0644 community-keyring/community-trusted /usr/share/pacman/keyrings/
sudo install -m0644 community-keyring/community-revoked /usr/share/pacman/keyrings/
sudo rm -r community-keyring
fi
# Initialize keys
sudo pacman-key --init
sudo pacman-key --populate
sudo pacman -Sy --quiet --noconfirm
# Adjust mkinitcpio hooks
msg "Adjusting mkinitcpio hooks"
sudo sed -i -e 's/File/Path/' /usr/share/libalpm/hooks/*hook*
# Create device node
msg "Creating device node /dev/sr0"
sudo mknod /dev/sr0 b 11 0 || true
sudo chmod 660 /dev/sr0 || true
sudo chown root:root /dev/sr0 || true
- name: Set environment variables
shell: bash
run: |
source /tmp/terminal_utils.sh
msg "Setting environment variables"
# Determine distroname for ISO profiles
DISTRONAME_ISOPROFILES="${{ inputs.distroname }}"
# Write environment variables
{
echo "USERNAME=builduser"
echo "HOME_FOLDER=/home/builduser"
echo "ISO_PROFILES_REPO=${{ inputs.iso_profiles_repo }}"
echo "EDITION=${{ inputs.edition }}"
echo "WORK_PATH=/__w/build-iso/build-iso"
echo "WORK_PATH_ISO_PROFILES=/__w/build-iso/build-iso/iso-profiles"
echo "DISTRONAME=${{ inputs.distroname }}"
echo "DISTRONAME_ISOPROFILES=$DISTRONAME_ISOPROFILES"
echo "PROFILE_PATH=/__w/build-iso/build-iso/iso-profiles/${DISTRONAME_ISOPROFILES}"
echo "PROFILE_PATH_EDITION=/__w/build-iso/build-iso/iso-profiles/${DISTRONAME_ISOPROFILES}/${{ inputs.edition }}"
echo "PATH_MANJARO_ISO_PROFILES=/usr/share/manjaro-tools/iso-profiles"
echo "PATH_MANJARO_TOOLS=/usr/share/manjaro-tools"
echo "VAR_CACHE_MANJARO_TOOLS=/var/cache/manjaro-tools"
echo "VAR_CACHE_MANJARO_TOOLS_ISO=/var/cache/manjaro-tools/iso"
echo "DEBUG=${{ inputs.tmate }}"
echo "MANJARO_BRANCH=${{ inputs.manjaro_branch }}"
echo "BIGCOMMUNITY_BRANCH=${{ inputs.community_branch }}"
echo "BIGLINUX_BRANCH=${{ inputs.biglinux_branch }}"
echo "KERNEL=${{ inputs.kernel }}"
echo "RELEASE_TAG=${{ inputs.release_tag }}"
echo "SCOPE=minimal"
echo "OFFICE=false"
} >> "$GITHUB_ENV"
- name: Build ISO
id: build
shell: bash
run: |
source /tmp/terminal_utils.sh
msg "Starting ISO build process"
# Execute the existing build-iso.sh script directly
chmod +x ./build-iso.sh
./build-iso.sh
# Check exit code
BUILD_EXIT_CODE=$?
if [ $BUILD_EXIT_CODE -ne 0 ]; then
# Send failure notification
link_action="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
FAILURE_MESSAGE="🚨 <b>ISO BUILD FAILED:</b>
<b>Job:</b> <code>#${GITHUB_RUN_NUMBER}</code>
<b>Distribution:</b> <code>${DISTRONAME}</code>
<b>Edition:</b> <code>${EDITION}</code>
<b>Error URL:</b> <a href='${link_action}'>${link_action}</a>
<b>Exit Code:</b> <code>${BUILD_EXIT_CODE}</code>"
send_telegram_message "$FAILURE_MESSAGE" "HTML"
die "ISO build failed with exit code ${BUILD_EXIT_CODE}"
fi
msg_ok "ISO build completed successfully"
- name: Setup tmate session for debugging
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.tmate == true }}
with:
install-dependencies: false
detached: true
- name: Set ISO path for output
shell: bash
run: |
source /tmp/terminal_utils.sh
msg "Setting ISO path for output"
echo "ISO_PATH=$WORK_PATH/$ISO_BASENAME" >> $GITHUB_ENV
msg_ok "ISO path set to: $WORK_PATH/$ISO_BASENAME"