Build ImageBuilder images #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }} |