-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathbuild-armbian-arm64-docker-image.yml
More file actions
146 lines (127 loc) · 5.53 KB
/
build-armbian-arm64-docker-image.yml
File metadata and controls
146 lines (127 loc) · 5.53 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
#=====================================================================================
# https://github.com/ophub/amlogic-s9xxx-armbian
# Description: Build and publish Armbian arm64 Docker image
# Instructions: https://github.com/docker/build-push-action
# Build and Push to: https://hub.docker.com/
#=====================================================================================
name: Build Armbian arm64 Docker image
on:
repository_dispatch:
workflow_dispatch:
inputs:
source_branch:
description: "Select the source branch"
required: false
default: "trixie"
type: choice
options:
- trixie
- bookworm
- resolute
- noble
- jammy
docker_img:
description: "Set the docker image"
required: false
default: "ophub/armbian"
type: choice
options:
- ophub/armbian
env:
TZ: Etc/UTC
MAKE_DOCKER_SH: compile-kernel/tools/script/docker/build_armbian_docker_image.sh
jobs:
build:
runs-on: ubuntu-24.04-arm
if: ${{ github.event.repository.owner.id == github.event.sender.id }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download Armbian rootfs file [ ${{ inputs.source_branch }} ]
id: down
if: (!cancelled())
run: |
# Retrieve the latest Armbian rootfs file from releases
latest_version=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases?per_page=20 | \
jq -r --arg RTK "Armbian_${{ inputs.source_branch }}_arm64_" \
--arg BOARD "rootfs" \
'[.[] | select(.tag_name | contains($RTK)) |
{tag: .tag_name} + (.assets[] | select(.name | contains($BOARD) and endswith(".tar.gz")) |
{data: .updated_at, url: .url, name: .name})] |
sort_by(.data) |
reverse |
.[0]')
[[ -z "${latest_version}" || "${latest_version}" == "null" ]] && {
echo "Error: Failed to resolve Armbian rootfs download URL."
exit 1
}
# Extract download URL, filename, and release tag
latest_url="$(echo ${latest_version} | jq -r '.url')"
armbian_filename="$(echo ${latest_version} | jq -r '.name')"
release_tag="$(echo ${latest_version} | jq -r '.tag')"
echo "Matched release tag: ${release_tag}"
echo "build_tag=${release_tag}" >> ${GITHUB_OUTPUT}
# Download asset via GitHub API (binary stream)
echo "Downloading: ${armbian_filename}"
[[ -d "armbian" ]] || mkdir -p armbian
curl -fsSL \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/octet-stream" \
"${latest_url}" \
-o "armbian/${armbian_filename}"
[[ "${?}" -ne "0" ]] && echo "Error: Download failed." && exit 1
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Build the Docker image
id: make
if: ${{ steps.down.outputs.status == 'success' && !cancelled() }}
run: |
chmod +x ${MAKE_DOCKER_SH}
${MAKE_DOCKER_SH} ${{ inputs.source_branch }} arm64
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Upload rebuilt images to Release
uses: ncipollo/release-action@main
if: ${{ steps.make.outputs.status == 'success' && !cancelled() }}
with:
tag: ${{ steps.down.outputs.build_tag }}
artifacts: out/*.tar.gz
allowUpdates: true
removeArtifacts: false
replacesArtifacts: true
makeLatest: true
token: ${{ secrets.GITHUB_TOKEN }}
body: |
### Armbian Image Information
- Default username: `root`
- Default password: `1234`
- Install command: `armbian-install`
- Update command: `armbian-update`
### Applicable Platform
- 🐧 `arm64`
- 🐋 Docker image: https://hub.docker.com/u/ophub
- name: Login to Docker Hub
id: login
if: ${{ steps.make.outputs.status == 'success' && !cancelled() }}
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Load and push image to Docker Hub
id: push
if: ${{ steps.make.outputs.status == 'success' && !cancelled() }}
run: |
# Load the offline Docker image built by build_armbian_docker_image.sh
offline_image="$(ls out/*.tar.gz 2>/dev/null | head -n 1)"
[[ -z "${offline_image}" ]] && echo "Error: No offline image found." && exit 1
loaded_image="$(docker load -i "${offline_image}" | grep -oP 'Loaded image: \K.*')"
[[ -z "${loaded_image}" ]] && echo "Error: Failed to load Docker image." && exit 1
echo "Loaded image: ${loaded_image}"
# Tag for Docker Hub
docker tag "${loaded_image}" "${{ inputs.docker_img }}-${{ inputs.source_branch }}:arm64"
docker tag "${loaded_image}" "${{ inputs.docker_img }}-${{ inputs.source_branch }}:latest"
# Push to Docker Hub
docker push "${{ inputs.docker_img }}-${{ inputs.source_branch }}:arm64"
docker push "${{ inputs.docker_img }}-${{ inputs.source_branch }}:latest"
echo "status=success" >> ${GITHUB_OUTPUT}