-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (51 loc) · 2.04 KB
/
publish.yml
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
name: Publish Home Assistant Add-ons
on:
push:
branches:
- main
paths:
- 'twingate/**'
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
addon: [twingate] # all add-ons
architecture: [armv7, aarch64, amd64, i386] # all architectures
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get changed folders
id: get_changed_folders
run: |
echo "Changed folders: ${{ github.event.head_commit.modified }}"
echo "::set-output name=changed_folders::${{ github.event.head_commit.modified }}"
echo "${{ github.event.head_commit.modified }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Authenticate GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.HA_GITHUB_TOKEN }}
- name: Set lowercase repository and owner names
run: |
echo "REPO_NAME_LC=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Set BUILD_FROM, PLATFORM, and VERSION variables
run: |
BUILD_FROM=$(yq e ".build_from.${{ matrix.architecture }}" ./${{ matrix.addon }}/build.yaml)
PLATFORM=$(yq e ".platform.${{ matrix.architecture }}" ./${{ matrix.addon }}/build.yaml)
VERSION=$(yq e ".version" ./${{ matrix.addon }}/config.yaml)
echo "BUILD_FROM=${BUILD_FROM}" >> $GITHUB_ENV
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Build and push Docker images
run: |
docker buildx build --platform linux/${{ env.PLATFORM }} \
--build-arg BUILD_FROM=${{ env.BUILD_FROM }} \
--push \
-t ghcr.io/${{ env.REPO_NAME_LC }}-${{ matrix.addon }}-${{ matrix.architecture }}:${{ env.VERSION }} \
./${{ matrix.addon }}