Skip to content

Build

Build #105

Workflow file for this run

name: Build
on:
schedule:
- cron: '45 9 * * 1-4'
workflow_dispatch:
push:
branches:
- main
paths:
- Dockerfile
- rootfs/**
pull_request:
branches:
- main
jobs:
init:
name: Init image build
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'home-assistant' }}
outputs:
target: ${{ steps.target.outputs.version }}
tag: ${{ steps.version.outputs.string }}
new_image: ${{ github.event_name == 'pull_request' || steps.existing_image.outcome == 'failure' }}
steps:
- uses: actions/checkout@v4.2.2
- name: Target version
id: target
run: |
echo "version=$(curl -sSL https://version.home-assistant.io/beta.json | jq -r '.homeassistant.default')" >> $GITHUB_OUTPUT
- name: Set version string
id: version
run: |
echo "string=${{ steps.target.outputs.version }}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Check if image exist
id: existing_image
if: ${{ github.event_name != 'pull_request' }}
continue-on-error: true
run: |
docker pull ghcr.io/${{ github.repository_owner }}/private-demo:${{ steps.version.outputs.string }}
build:
name: Build image
runs-on: ubuntu-latest
needs:
- "init"
if: ${{ needs.init.outputs.new_image }}
environment: ${{ github.event_name != 'pull_request' && 'build' || '' }}
steps:
- uses: actions/checkout@v4.2.2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v6.9.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
build-args: |
TARGET_VERSION=${{ needs.init.outputs.target }}
tags: "ghcr.io/${{ github.repository_owner }}/private-demo:${{ needs.init.outputs.tag }}"