Build docker images #124
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
name: Build docker images | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/build.yml' | |
- 'create_bootstrap_archlinux.sh' | |
- 'arm_gcc.sh' | |
- 'aarch64_gcc.sh' | |
- 'i686_binutils.sh' | |
- 'Dockerfile' | |
pull_request: | |
paths: | |
- '.github/workflows/build.yml' | |
- 'create_bootstrap_archlinux.sh' | |
- 'arm_gcc.sh' | |
- 'aarch64_gcc.sh' | |
- 'i686_binutils.sh' | |
- 'Dockerfile' | |
schedule: | |
- cron: '0 0 * * 0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [aarch64, armv7h, i686, x86_64] | |
fail-fast: false | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: 'arm64,arm' | |
- name: Get bootstrap | |
run: ./create_bootstrap_archlinux.sh "${{ matrix.arch }}" | |
- name: Build images docker | |
run: | | |
case "${{ matrix.arch }}" in | |
aarch64) platform="linux/arm64";; | |
armv7h) platform="linux/arm/v7";; | |
x86_64) platform="linux/amd64";; | |
i686) platform="linux/386";; | |
esac | |
cat "archlinux-${{ matrix.arch }}.tar.gz" | docker import --platform "$platform" - archlinux-builder:bootstrap | |
docker build --platform="$platform" -t "ghcr.io/termux-pacman/archlinux-builder:${{ matrix.arch }}" . | |
docker save --output archlinux-builder-${{ matrix.arch }}.tar "ghcr.io/termux-pacman/archlinux-builder:${{ matrix.arch }}" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: archlinux-builder-${{ matrix.arch }} | |
path: archlinux-builder-${{ matrix.arch }}.tar | |
if-no-files-found: error | |
push: | |
if: github.event_name != 'pull_request' | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [aarch64, armv7h, i686, x86_64] | |
fail-fast: false | |
steps: | |
- name: Get docker images | |
uses: actions/download-artifact@v4 | |
with: | |
name: archlinux-builder-${{ matrix.arch }} | |
path: ./ | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push docker images | |
run: | | |
docker load < archlinux-builder-${{ matrix.arch }}.tar | |
docker push ghcr.io/termux-pacman/archlinux-builder:${{ matrix.arch }} |