Skip to content

Nightly Docker build #220

Nightly Docker build

Nightly Docker build #220

name: Nightly Docker build
on:
workflow_dispatch: null
schedule:
- cron: '0 2 * * *'
env:
REGISTRY: ghcr.io
jobs:
matrix:
runs-on: ubuntu-latest
name: Get matrix from json
outputs:
matrix: ${{ steps.vars.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up variables
id: vars
run: echo "matrix=$(jq -c . matrix.json)" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: Build for ${{ matrix.image_name }}
needs: [matrix]
strategy:
max-parallel: 2
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.image_name }}-nightly-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.image_name }}-nightly-
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/[email protected]
with:
push: false
load: true
tags: |
${{ env.REGISTRY }}/congatudo/congatudo-nightly:${{ matrix.image_name }}-latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args: |
"BUILD_FROM=${{ matrix.build_from }}"
"PKG_TARGET=${{ matrix.pkg_target }}"
"PKG_OPTIONS=${{ matrix.pkg_options }}"
- name: Test
shell: '/bin/bash {0}'
run: |
docker run --rm ${{ env.REGISTRY }}/congatudo/congatudo-nightly:${{ matrix.image_name }}-latest
ret=$?
if [ $ret -eq 1 ]; then
exit 0
else
exit $ret
fi
- name: Push
run: |
docker push ${{ env.REGISTRY }}/congatudo/congatudo-nightly:${{ matrix.image_name }}-latest
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
manifest:
runs-on: ubuntu-latest
name: Create and push manifest
needs: [build]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest
run: |
# TODO: Use matrix here.
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-armv7-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-aarch64-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-amd64-latest
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-armhf-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-armv7-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-aarch64-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-amd64-latest
- name: Push manifest
run: |
# TODO: Use matrix here.
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-latest
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-latest