-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathbuild-armbian-x86-server-image.yml
More file actions
179 lines (164 loc) · 6.95 KB
/
build-armbian-x86-server-image.yml
File metadata and controls
179 lines (164 loc) · 6.95 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
#==========================================================================
# Description: Build Armbian x86 server image
# Copyright (C) 2021 https://github.com/ophub/amlogic-s9xxx-armbian
#==========================================================================
name: Build Armbian x86 server image
on:
repository_dispatch:
workflow_dispatch:
inputs:
set_release:
description: "Select OS Release."
required: false
default: "noble"
type: choice
options:
- trixie
- bookworm
- noble
- jammy
publish_docker:
description: "Publish Docker image"
required: false
default: "none"
type: choice
options:
- ophub/armbian
- none
env:
TZ: Etc/UTC
ROOTFS_SCRIPT: compile-kernel/tools/script/docker/build_armbian_rootfs_file.sh
MAKE_DOCKER_SH: compile-kernel/tools/script/docker/build_armbian_docker_image.sh
DOCKER_OUTPATH: out
jobs:
build:
runs-on: ubuntu-24.04
if: ${{ github.event.repository.owner.id == github.event.sender.id }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Initialization environment
id: init
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi -f $(docker images -q) 2>/dev/null || true
[[ -n "${AGENT_TOOLSDIRECTORY}" ]] && sudo rm -rf "${AGENT_TOOLSDIRECTORY}"
sudo rm -rf /usr/share/dotnet /usr/local/lib/android 2>/dev/null
sudo swapoff -a
sudo rm -f /swapfile /mnt/swapfile
sudo -E apt-get -y update
sudo -E apt-get -y purge azure-cli ghc* zulu* llvm* firefox google* dotnet* powershell openjdk* mongodb* moby* || true
sudo -E apt-get -y install $(curl -fsSL https://ophub.org/ubuntu2404-build-armbian-depends)
sudo -E systemctl daemon-reload
#sudo -E apt-get -y full-upgrade
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
sudo rm -rf ~/{.cargo,.dotnet,.rustup}
sudo -E timedatectl set-timezone "${TZ:-Etc/UTC}"
sudo -E ntpdate ntp.ubuntu.com 0.pool.ntp.org || true
sudo -E timedatectl set-ntp true
date -u
timedatectl status || true
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Create simulated physical disk
run: |
mnt_size=$(expr $(df -h /mnt | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 1)
root_size=$(expr $(df -h / | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 4)
sudo truncate -s "${mnt_size}"G /mnt/mnt.img
sudo truncate -s "${root_size}"G /root.img
sudo losetup /dev/loop6 /mnt/mnt.img
sudo losetup /dev/loop7 /root.img
sudo pvcreate /dev/loop6
sudo pvcreate /dev/loop7
sudo vgcreate github /dev/loop6 /dev/loop7
sudo lvcreate -n runner -l 100%FREE github
sudo mkfs.xfs -f -i sparse=0 -b size=4096 /dev/github/runner
sudo mkdir -p /builder
sudo mount /dev/github/runner /builder
sudo chown -R runner:runner /builder
df -Th
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Download source code
id: down
working-directory: /builder
if: ${{ steps.init.outputs.status == 'success' && !cancelled() }}
run: |
df -hT ${PWD}
git clone -q --single-branch --depth=1 --branch=main https://github.com/armbian/build.git build
ln -sf /builder/build ${{ github.workspace }}/build
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Compile Armbian [ ${{ inputs.set_release }} ]
id: compile
working-directory: /builder
if: ${{ steps.down.outputs.status == 'success' && !cancelled() }}
run: |
run: |
# Enable QEMU emulation for ARM architecture
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 2>/dev/null || true
# Compile method and parameter description: https://docs.armbian.com/Developer-Guide_Build-Options
cd build/
./compile.sh RELEASE=${{ inputs.set_release }} BOARD=uefi-x86 BRANCH=current BUILD_MINIMAL=no \
BUILD_ONLY=default HOST=armbian BUILD_DESKTOP=no EXPERT=yes KERNEL_CONFIGURE=no \
COMPRESS_OUTPUTIMAGE="sha" SHARE_LOG=yes
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Organize files and clear space
id: clean
if: ${{ steps.compile.outputs.status == 'success' && !cancelled() }}
run: |
# Organize and keep essential files, delete unnecessary files
chmod +x ${ROOTFS_SCRIPT}
${ROOTFS_SCRIPT} -v ${{ inputs.set_release }} -s true -c true -k false -p amd64
# Clean build directory except output folder
[[ -d "armbian" ]] || mkdir armbian
cp -af build/output/images/* armbian/
rm -rf build
# Output cleaning result information
df -hT ${PWD}
echo "build_tag=Armbian_${{ inputs.set_release }}_amd64_server_$(date +"%Y.%m")" >> ${GITHUB_ENV}
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Upload Armbian image to Release
uses: ncipollo/release-action@main
if: ${{ steps.clean.outputs.status == 'success' && !cancelled() }}
with:
tag: ${{ env.build_tag }}
artifacts: armbian/*
allowUpdates: true
makeLatest: false
token: ${{ secrets.GITHUB_TOKEN }}
body: |
### Armbian Image information
- Default username: `root`
- Default password: `1234`
### Applicable platform
- 💻 `amd64(uefi-x86)`
- 🐋 Docker image: https://hub.docker.com/u/ophub
- name: Build the Docker image
id: makedocker
if: ${{ inputs.publish_docker != 'none' && !cancelled() }}
run: |
chmod +x ${MAKE_DOCKER_SH}
${MAKE_DOCKER_SH}
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Set up Docker Buildx
id: buildx
if: ${{ steps.makedocker.outputs.status == 'success' && !cancelled() }}
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
id: login
if: ${{ steps.makedocker.outputs.status == 'success' && !cancelled() }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push to Docker Hub
id: push
if: ${{ steps.makedocker.outputs.status == 'success' && !cancelled() }}
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64
context: ${{ env.DOCKER_OUTPATH }}
tags: |
"${{ inputs.publish_docker }}-${{ inputs.set_release }}:amd64"