-
Notifications
You must be signed in to change notification settings - Fork 9
103 lines (89 loc) · 3.08 KB
/
imagebuilder.yml
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
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
name: Build ImageBuilder images
on:
workflow_dispatch:
inputs:
branch:
description: "Source branch"
required: true
default: "master"
version:
description: "Release version"
required: true
default: "snapshot"
jobs:
generate_targets:
name: Generate target list
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.list_targets.outputs.targets }}
steps:
- name: Checkout ImmortalWrt source tree
uses: actions/checkout@v4
with:
repository: "immortalwrt/immortalwrt"
ref: ${{ github.event.inputs.branch }}
- name: Generate target list
id: list_targets
run: |
for TARGET in $(perl ./scripts/dump-target-info.pl targets 2>/dev/null | awk '{ print $1 }'); do \
TARGET_LIST="${TARGET_LIST:+$TARGET_LIST,}\"${TARGET/\//-}\""; \
done
JSON_LIST="{\"runner\": [\"ubuntu-latest\"],\"targets\":[$TARGET_LIST]}"
echo "$JSON_LIST" | jq .
echo "targets=$JSON_LIST" >> "$GITHUB_OUTPUT"
build:
name: Build ImageBuilder image for ${{ matrix.targets }}
needs: generate_targets
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate_targets.outputs.targets)}}
max-parallel: 10
steps:
- name: Free disk spaces
env:
DEBIAN_FRONTEND: noninteractive
run: |
for i in $(docker images -q); do docker rmi "$i"; done
sudo -E apt-get -y purge azure-cli dotnet* firefox ghc* google* llvm* moby* mongodb* openjdk* powershell zulu*
sudo -E apt-get -y autoremove --purge
sudo -E rm -rf $AGENT_TOOLSDIRECTORY /usr/local/lib/android /usr/share/dotnet
- name: Checkout docker repo
uses: actions/checkout@v4
- name: Download ImageBuilder for ${{ matrix.targets }}
run: ./download_files.sh ib
env:
TARGET: ${{ matrix.targets }}
VERSION: ${{ github.event.inputs.version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build base image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.base
platforms: linux/amd64
push: false
tags: immortalwrt:base
- name: Build and push ImageBuilder image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.ib
platforms: linux/amd64
push: true
tags: |
immortalwrt/imagebuilder:${{ matrix.targets }}-${{ github.event.inputs.branch }}
immortalwrt/imagebuilder:${{ matrix.targets }}-${{ github.event.inputs.version }}