-
Notifications
You must be signed in to change notification settings - Fork 4
71 lines (63 loc) · 2.08 KB
/
build.yaml
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
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/[email protected]
- 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/[email protected]
- name: Login to GitHub Container Registry
uses: docker/[email protected]
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/[email protected]
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 }}"