2020-08-26 16:47:31 +02:00
|
|
|
name: Build addon
|
|
|
|
|
|
|
|
on:
|
2020-09-16 10:13:29 +02:00
|
|
|
push:
|
2024-08-27 18:41:18 +02:00
|
|
|
branches:
|
|
|
|
- "*"
|
2024-09-10 13:48:02 +02:00
|
|
|
tags:
|
2024-08-27 18:41:18 +02:00
|
|
|
- "*"
|
2024-09-03 11:20:21 +02:00
|
|
|
pull_request:
|
2020-08-26 16:47:31 +02:00
|
|
|
|
|
|
|
env:
|
|
|
|
TARGET: nextcloud_backup
|
2021-02-10 15:40:08 +01:00
|
|
|
IMAGE: "hassio-nextcloud-backup"
|
|
|
|
REPOSITORY: ghcr.io/sebclem
|
2024-04-19 16:51:44 +02:00
|
|
|
IMAGE_SOURCE: https://github.com/Sebclem/hassio-nextcloud-backup
|
2024-09-12 09:39:13 +02:00
|
|
|
BASE_ISSUER: https://token.actions.githubusercontent.com
|
|
|
|
BASE_IDENTITY: https://github.com/home-assistant/docker-base/.*
|
2020-08-26 16:47:31 +02:00
|
|
|
|
2024-09-10 17:15:39 +02:00
|
|
|
permissions: write-all
|
|
|
|
|
2020-10-12 14:26:45 +02:00
|
|
|
jobs:
|
2024-08-13 13:23:32 +02:00
|
|
|
build-front:
|
2024-04-19 16:51:44 +02:00
|
|
|
name: Build Front
|
2020-10-12 14:26:45 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-04-19 16:51:44 +02:00
|
|
|
- name: Checkout repo
|
2024-04-19 17:21:19 +02:00
|
|
|
uses: actions/checkout@v4
|
2020-10-12 14:26:45 +02:00
|
|
|
|
2024-04-19 16:51:44 +02:00
|
|
|
- name: Enable corepack
|
|
|
|
run: corepack enable
|
|
|
|
|
|
|
|
- name: Setup Node
|
2024-04-19 17:21:19 +02:00
|
|
|
uses: actions/setup-node@v4
|
2021-02-10 15:40:08 +01:00
|
|
|
with:
|
2024-04-19 16:51:44 +02:00
|
|
|
node-version: 20
|
|
|
|
cache: "pnpm"
|
|
|
|
cache-dependency-path: nextcloud_backup/frontend/pnpm-lock.yaml
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm i
|
|
|
|
working-directory: nextcloud_backup/frontend
|
2021-02-10 15:40:08 +01:00
|
|
|
|
2024-04-19 16:51:44 +02:00
|
|
|
- name: Build
|
|
|
|
run: pnpm build
|
|
|
|
working-directory: nextcloud_backup/frontend
|
|
|
|
|
|
|
|
- name: Upload production-ready build files
|
2024-04-19 17:21:19 +02:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-02-10 15:40:08 +01:00
|
|
|
with:
|
2024-09-11 16:17:17 +02:00
|
|
|
name: frontend
|
2024-04-19 17:21:19 +02:00
|
|
|
path: nextcloud_backup/frontend/dist/
|
2024-04-19 16:51:44 +02:00
|
|
|
|
2024-08-13 13:23:32 +02:00
|
|
|
build-back:
|
2024-08-13 13:26:11 +02:00
|
|
|
name: Build back
|
2024-08-13 13:23:32 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Enable corepack
|
|
|
|
run: corepack enable
|
|
|
|
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: 20
|
|
|
|
cache: "pnpm"
|
|
|
|
cache-dependency-path: nextcloud_backup/backend/pnpm-lock.yaml
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm i
|
|
|
|
working-directory: nextcloud_backup/backend
|
|
|
|
|
|
|
|
- name: Lint
|
|
|
|
run: pnpm lint
|
|
|
|
working-directory: nextcloud_backup/backend
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: pnpm build
|
|
|
|
working-directory: nextcloud_backup/backend
|
|
|
|
|
|
|
|
- name: Upload production-ready build files
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
2024-09-11 16:17:17 +02:00
|
|
|
name: backend
|
2024-08-13 13:23:32 +02:00
|
|
|
path: nextcloud_backup/backend/dist/
|
|
|
|
|
2024-08-13 13:47:22 +02:00
|
|
|
build-dockers:
|
|
|
|
runs-on: ubuntu-latest
|
2024-08-14 16:19:40 +02:00
|
|
|
needs:
|
|
|
|
- build-back
|
|
|
|
- build-front
|
2024-08-13 13:47:22 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-09-10 13:48:02 +02:00
|
|
|
arch: [aarch64, amd64, armv7]
|
2024-08-13 13:47:22 +02:00
|
|
|
include:
|
|
|
|
- arch: aarch64
|
|
|
|
arch_value: linux/arm64/v8
|
|
|
|
- arch: amd64
|
|
|
|
arch_value: linux/amd64
|
|
|
|
- arch: armv7
|
|
|
|
arch_value: linux/arm/v7
|
2024-08-13 15:35:35 +02:00
|
|
|
|
2024-08-13 13:47:22 +02:00
|
|
|
steps:
|
2024-08-13 16:39:04 +02:00
|
|
|
- uses: actions/checkout@v4
|
2024-08-13 13:47:22 +02:00
|
|
|
|
2024-09-10 16:56:26 +02:00
|
|
|
- name: Install Cosign
|
2024-10-23 02:04:09 +02:00
|
|
|
uses: sigstore/cosign-installer@v3.7.0
|
2024-09-10 16:56:26 +02:00
|
|
|
|
2024-08-13 13:47:22 +02:00
|
|
|
- name: Set up QEMU
|
2024-08-13 16:39:04 +02:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2024-08-13 13:47:22 +02:00
|
|
|
|
2024-09-11 11:26:31 +02:00
|
|
|
- name: Set up Docker Buildx
|
2024-08-13 16:39:04 +02:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2024-08-13 13:47:22 +02:00
|
|
|
|
2024-09-11 16:17:17 +02:00
|
|
|
- name: Get build parameters
|
|
|
|
id: build_param
|
2024-08-13 13:47:22 +02:00
|
|
|
run: |
|
2024-09-11 16:17:17 +02:00
|
|
|
echo "name=$(yq .name nextcloud_backup/config.yml)" >> $GITHUB_OUTPUT
|
|
|
|
echo "description=$(yq .description nextcloud_backup/config.yml)" >> $GITHUB_OUTPUT
|
|
|
|
echo "url=$(yq .url nextcloud_backup/config.yml)" >> $GITHUB_OUTPUT
|
2024-09-11 11:26:31 +02:00
|
|
|
echo "build_from=ghcr.io/home-assistant/${{ matrix.arch }}-base:$(cat nextcloud_backup/.base_version)" >> $GITHUB_OUTPUT
|
2024-08-13 13:47:22 +02:00
|
|
|
|
2024-09-12 09:39:13 +02:00
|
|
|
- name: Check base image signature
|
|
|
|
run: cosign verify --certificate-oidc-issuer-regexp "${{ env.BASE_ISSUER }}" --certificate-identity-regexp "${{ env.BASE_IDENTITY }}" "${{ steps.build_param.outputs['build_from'] }}"
|
|
|
|
|
2024-08-13 16:06:17 +02:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: |
|
2024-09-11 11:26:31 +02:00
|
|
|
${{ env.REPOSITORY }}/${{ env.IMAGE }}/${{ matrix.arch }}
|
2024-08-13 16:06:17 +02:00
|
|
|
tags: |
|
2024-08-26 16:22:07 +02:00
|
|
|
type=ref,event=branch
|
2024-08-26 15:58:25 +02:00
|
|
|
type=ref,event=branch,suffix=.${{ github.run_number }}
|
2024-08-13 16:06:17 +02:00
|
|
|
type=ref,event=pr
|
|
|
|
type=semver,pattern={{version}}
|
2024-09-10 13:48:02 +02:00
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2024-08-13 16:06:17 +02:00
|
|
|
labels: |
|
2024-09-11 16:17:17 +02:00
|
|
|
io.hass.name=${{ steps.build_param.outputs['name'] }}
|
|
|
|
io.hass.description=${{ steps.build_param.outputs['description'] }}
|
|
|
|
io.hass.url=${{ steps.build_param.outputs['url'] }}
|
2024-09-11 11:26:31 +02:00
|
|
|
io.hass.arch=${{ matrix.arch }}
|
2024-09-10 13:48:02 +02:00
|
|
|
io.hass.type=addon
|
2024-08-13 13:47:22 +02:00
|
|
|
|
2024-09-11 11:26:31 +02:00
|
|
|
- name: Change version in config file
|
|
|
|
uses: fjogeleit/yaml-update-action@v0.15.0
|
|
|
|
with:
|
|
|
|
valueFile: "nextcloud_backup/config.yml"
|
|
|
|
propertyPath: "version"
|
|
|
|
value: ${{ steps.meta.outputs.version }}.${{ github.run_number}}
|
|
|
|
commitChange: false
|
2024-08-13 13:47:22 +02:00
|
|
|
|
|
|
|
- name: Login to ghcr.io
|
2024-08-13 16:39:04 +02:00
|
|
|
uses: docker/login-action@v3
|
2024-08-13 13:47:22 +02:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build and push ${{matrix.arch}}
|
2024-08-13 16:39:04 +02:00
|
|
|
uses: docker/build-push-action@v6
|
2024-09-10 16:56:26 +02:00
|
|
|
id: build-and-push
|
2024-08-13 13:47:22 +02:00
|
|
|
with:
|
2024-08-26 16:07:29 +02:00
|
|
|
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.event_name == 'release') }}
|
2024-08-13 16:06:17 +02:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
2024-08-13 16:29:19 +02:00
|
|
|
labels: |
|
|
|
|
${{ steps.meta.outputs.labels }}
|
|
|
|
io.hass.version=${{steps.meta.outputs.version}}
|
2024-08-13 13:47:22 +02:00
|
|
|
build-args: |
|
2024-09-11 16:17:17 +02:00
|
|
|
BUILD_FROM=${{ steps.build_param.outputs['build_from'] }}
|
2024-09-11 11:26:31 +02:00
|
|
|
file: ./${{ env.TARGET }}/Dockerfile
|
|
|
|
cache-from: type=registry,ref=${{ env.REPOSITORY }}/${{ env.IMAGE }}/${{ matrix.arch }}:latest
|
2024-08-13 13:47:22 +02:00
|
|
|
cache-to: type=inline
|
2024-09-11 11:26:31 +02:00
|
|
|
context: ./${{ env.TARGET }}/
|
2024-08-13 13:47:22 +02:00
|
|
|
platforms: ${{ matrix.arch_value }}
|
2024-08-26 16:06:32 +02:00
|
|
|
|
2024-09-10 16:56:26 +02:00
|
|
|
- name: Sign the images with GitHub OIDC Token
|
|
|
|
if: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.event_name == 'release') }}
|
|
|
|
env:
|
|
|
|
DIGEST: ${{ steps.build-and-push.outputs.digest }}
|
|
|
|
TAGS: ${{ steps.meta.outputs.tags }}
|
|
|
|
run: |
|
|
|
|
images=""
|
|
|
|
for tag in ${TAGS}; do
|
|
|
|
images+="${tag}@${DIGEST} "
|
|
|
|
done
|
2024-09-10 17:15:39 +02:00
|
|
|
cosign sign --yes ${images}
|
2024-09-10 16:56:26 +02:00
|
|
|
|
2024-09-11 14:56:16 +02:00
|
|
|
update_branch_ha_repository:
|
2024-08-26 16:22:07 +02:00
|
|
|
name: Update HA addon repository
|
2024-08-26 16:06:32 +02:00
|
|
|
runs-on: ubuntu-latest
|
2024-09-10 13:48:02 +02:00
|
|
|
needs:
|
2024-08-26 16:06:32 +02:00
|
|
|
- build-dockers
|
2024-08-27 18:41:18 +02:00
|
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
2024-08-26 16:06:32 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v4
|
2024-09-10 13:48:02 +02:00
|
|
|
with:
|
2024-08-26 16:06:32 +02:00
|
|
|
path: "addon"
|
2024-09-10 14:36:20 +02:00
|
|
|
|
|
|
|
- name: Get branch names
|
|
|
|
id: branch-names
|
|
|
|
uses: tj-actions/branch-names@v8
|
|
|
|
|
2024-08-26 16:06:32 +02:00
|
|
|
- name: Checkout Hass repo
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
2024-09-10 13:48:02 +02:00
|
|
|
repository: Sebclem/sebclem-hassio-addon-repository
|
|
|
|
path: "repository"
|
2024-09-10 14:18:02 +02:00
|
|
|
token: ${{ secrets.PAT_PR }}
|
2024-09-10 14:36:20 +02:00
|
|
|
ref: ${{ steps.branch-names.outputs.current_branch }}
|
2024-08-26 16:06:32 +02:00
|
|
|
|
|
|
|
- name: Generate readme
|
|
|
|
uses: cuchi/jinja2-action@v1.2.2
|
2024-09-10 13:48:02 +02:00
|
|
|
with:
|
2024-08-26 16:06:32 +02:00
|
|
|
template: addon/nextcloud_backup/.README.md.j2
|
|
|
|
output_file: repository/nextcloud_backup/README.md
|
|
|
|
variables: version=${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number}}
|
|
|
|
|
|
|
|
- name: Move other files
|
|
|
|
run: |
|
|
|
|
cp addon/nextcloud_backup/DOCS.md repository/nextcloud_backup/
|
|
|
|
cp addon/nextcloud_backup/icon.png repository/nextcloud_backup/
|
|
|
|
cp addon/nextcloud_backup/logo.png repository/nextcloud_backup/
|
|
|
|
cp addon/nextcloud_backup/config.yml repository/nextcloud_backup/
|
2024-09-10 13:48:02 +02:00
|
|
|
|
2024-09-11 16:17:17 +02:00
|
|
|
- name: Update config.yml
|
|
|
|
run: |
|
2024-09-11 16:25:38 +02:00
|
|
|
yq -i '.version = "${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number}}"' repository/nextcloud_backup/config.yml
|
|
|
|
yq -i '.image = "ghcr.io/sebclem/hassio-nextcloud-backup/{arch}"' repository/nextcloud_backup/config.yml
|
2024-09-10 13:48:02 +02:00
|
|
|
|
|
|
|
- name: Commit and push
|
2024-09-10 14:18:02 +02:00
|
|
|
run: |
|
|
|
|
cd repository
|
|
|
|
git config user.name "github-actions[bot]"
|
|
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
git add .
|
|
|
|
git commit -m "Update Nextcloud Backup to ${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number }}"
|
|
|
|
git push
|
2024-09-11 14:56:16 +02:00
|
|
|
|
|
|
|
draft-release:
|
|
|
|
name: Draft release
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- build-dockers
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
steps:
|
2024-09-11 15:09:21 +02:00
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v4
|
2024-09-11 14:56:16 +02:00
|
|
|
- name: Get changelog
|
|
|
|
run: npx auto-changelog --handlebars-setup .github/custom-handlebars.js
|
|
|
|
- name: Create release
|
|
|
|
uses: softprops/action-gh-release@v2
|
|
|
|
with:
|
2024-09-11 15:16:33 +02:00
|
|
|
body_path: CHANGELOG.md
|
2024-09-11 14:56:16 +02:00
|
|
|
draft: true
|