2020-08-26 16:47:31 +02:00
|
|
|
name: Build addon
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
2021-02-10 15:40:08 +01:00
|
|
|
types: [ published ]
|
2020-09-16 10:13:29 +02:00
|
|
|
push:
|
2020-08-26 16:47:31 +02:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
env:
|
|
|
|
TARGET: nextcloud_backup
|
2021-02-10 15:40:08 +01:00
|
|
|
IMAGE: "hassio-nextcloud-backup"
|
|
|
|
REPOSITORY: ghcr.io/sebclem
|
2021-02-10 15:54:40 +01:00
|
|
|
IMAGE_SOURCE : https://github.com/Sebclem/hassio-nextcloud-backup
|
2020-08-26 16:47:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 14:26:45 +02:00
|
|
|
jobs:
|
2021-02-10 15:40:08 +01:00
|
|
|
build-dockers:
|
2020-10-12 14:26:45 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
2022-05-01 15:52:34 +02:00
|
|
|
fail-fast: false
|
2021-02-10 15:40:08 +01:00
|
|
|
matrix:
|
2022-05-01 15:52:34 +02:00
|
|
|
arch: [ aarch64, amd64, armv7, i386, armhf ]
|
|
|
|
include:
|
|
|
|
- arch: aarch64
|
|
|
|
arch_value: linux/arm64/v8
|
|
|
|
- arch: amd64
|
|
|
|
arch_value: linux/amd64
|
|
|
|
- arch: armv7
|
|
|
|
arch_value: linux/arm/v7
|
|
|
|
- arch: i386
|
|
|
|
arch_value: linux/386
|
|
|
|
- arch: armhf
|
|
|
|
arch_value: linux/arm/v6
|
2020-10-12 14:26:45 +02:00
|
|
|
steps:
|
|
|
|
|
2022-05-04 11:08:09 +02:00
|
|
|
- uses: actions/checkout@v3
|
2020-10-12 14:26:45 +02:00
|
|
|
|
2022-05-01 15:52:34 +02:00
|
|
|
- name: Set up QEMU
|
2022-05-13 13:50:09 +02:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2020-10-12 14:26:45 +02:00
|
|
|
|
2021-02-10 15:40:08 +01:00
|
|
|
- name: Set up Docker Buildx ${{matrix.arch}}
|
2022-05-13 13:49:57 +02:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2020-10-12 14:26:45 +02:00
|
|
|
|
2021-02-10 15:40:08 +01:00
|
|
|
- name: Set Version Prod ${{matrix.arch}}
|
|
|
|
if: github.event_name != 'workflow_dispatch' && github.event_name != 'push'
|
|
|
|
run: |
|
|
|
|
version=${GITHUB_REF/refs\/tags\//}
|
|
|
|
if [ -n "$version" ];then
|
|
|
|
tmp=$(mktemp)
|
|
|
|
jq --arg version "$version" '.version=$version' ${{env.TARGET}}/config.json > "$tmp" && mv "$tmp" ${{env.TARGET}}/config.json
|
|
|
|
fi
|
|
|
|
echo "version_type=prod" >> $GITHUB_ENV
|
|
|
|
- name: Set Version Test ${{matrix.arch}}
|
|
|
|
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
|
|
|
|
run: |
|
|
|
|
version=dev_${GITHUB_RUN_ID}
|
|
|
|
if [ -n "$version" ];then
|
|
|
|
tmp=$(mktemp)
|
|
|
|
jq --arg version "$version" '.version=$version' ${{env.TARGET}}/config.json > "$tmp" && mv "$tmp" ${{env.TARGET}}/config.json
|
|
|
|
fi
|
|
|
|
echo "version_type=dev" >> $GITHUB_ENV
|
2020-10-12 14:26:45 +02:00
|
|
|
|
|
|
|
|
2021-02-10 15:40:08 +01:00
|
|
|
- name: Get build option ${{matrix.arch}}
|
|
|
|
run: |
|
|
|
|
echo "NAME=$(jq --raw-output '.name // empty' "${{env.TARGET}}/config.json" | sed "s/'//g")" >> $GITHUB_ENV
|
|
|
|
echo "DESCRIPTION=$(jq --raw-output '.description // empty' "${{env.TARGET}}/config.json" | sed "s/'//g")" >> $GITHUB_ENV
|
|
|
|
echo "URL=$(jq --raw-output '.url // empty' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV
|
|
|
|
echo "VERSION=$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV
|
2021-03-23 15:16:12 +01:00
|
|
|
echo "BUILD_FROM=ghcr.io/hassio-addons/base/${{matrix.arch}}:$(cat nextcloud_backup/.base_version)" >> $GITHUB_ENV
|
2020-10-12 14:26:45 +02:00
|
|
|
|
2021-02-10 15:40:08 +01:00
|
|
|
- name: Set Tags ${{matrix.arch}}
|
|
|
|
run: |
|
|
|
|
if [ "${{env.version_type}}" != "dev" ]; then
|
|
|
|
echo "TAGS=${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}}:latest, ${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}}:$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "TAGS=${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}}:dev, ${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}}:$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV
|
|
|
|
fi
|
2020-10-12 14:26:45 +02:00
|
|
|
|
2021-02-10 15:40:08 +01:00
|
|
|
- name: Debug Env
|
|
|
|
run: |
|
|
|
|
echo ${{env.VERSION}}
|
|
|
|
echo ${{env.TAGS}}
|
|
|
|
|
|
|
|
- name: Login to ghcr.io
|
2022-05-13 13:49:44 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-02-10 15:40:08 +01:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
2022-04-30 16:27:37 +02:00
|
|
|
username: ${{ github.actor }}
|
2021-05-06 11:36:07 +02:00
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2021-02-10 15:40:08 +01:00
|
|
|
|
|
|
|
- name: Build and push ${{matrix.arch}}
|
2022-05-13 13:50:22 +02:00
|
|
|
uses: docker/build-push-action@v3
|
2021-02-10 15:40:08 +01:00
|
|
|
with:
|
2021-05-06 14:07:11 +02:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2021-02-10 15:40:08 +01:00
|
|
|
tags: ${{env.TAGS}}
|
|
|
|
labels: io.hass.name=${{env.NAME}}, io.hass.description=${{env.DESCRIPTION}}, io.hass.url=${{env.URL}}, io.hass.arch=${{matrix.arch}}, io.hass.version=${{env.VERSION}}, io.hass.type=addon
|
|
|
|
build-args: |
|
|
|
|
BUILD_FROM=${{env.BUILD_FROM}}
|
|
|
|
BUILD_VERSION=${{env.VERSION}}
|
2021-02-10 15:54:40 +01:00
|
|
|
IMAGE_SOURCE=${{env.IMAGE_SOURCE}}
|
2021-02-10 16:38:34 +01:00
|
|
|
file: ./${{env.TARGET}}/Dockerfile
|
2021-03-23 15:23:38 +01:00
|
|
|
cache-from: type=registry,ref=${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}}:latest
|
2021-05-06 11:36:07 +02:00
|
|
|
cache-to: type=inline
|
2021-05-06 14:07:11 +02:00
|
|
|
context: ./${{env.TARGET}}/
|
2022-05-01 15:52:34 +02:00
|
|
|
platforms: ${{ matrix.arch_value }}
|