Skip to content

Commit

Permalink
🎉 Extract addon from mono-repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Poeschl committed Sep 13, 2024
0 parents commit 01aa47b
Show file tree
Hide file tree
Showing 27 changed files with 785 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
GH actions:
dependency-type: production
- package-ecosystem: "npm"
directory: "/root/server"
schedule:
interval: "monthly"
groups:
npm:
dependency-type: production
210 changes: 210 additions & 0 deletions .github/workflows/addon-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
name: Deploy addon

on:
workflow_call:
secrets:
DISPATCH_TOKEN:
required: true

concurrency:
group: queue

jobs:
information:
if: github.event_name == 'release'
name: ℹ️ Gather add-on information
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.information.outputs.architectures }}
base_image_signer: ${{ steps.information.outputs.codenotary_base_image }}
build: ${{ steps.information.outputs.build }}
description: ${{ steps.information.outputs.description }}
environment: ${{ steps.release.outputs.environment }}
name: ${{ steps.information.outputs.name }}
signer: ${{ steps.information.outputs.codenotary_signer }}
slug: ${{ steps.override.outputs.slug }}
target: ${{ steps.information.outputs.target }}
version: ${{ steps.release.outputs.version }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4

- name: 🚀 Run add-on information action
id: information
uses: frenck/[email protected]

- name: ℹ️ Gather version from GitHub
id: release
run: |
version="${{ github.event.release.tag_name }}"
version="${version,,}"
version="${version#v}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
deploy:
name: 👷 Build & Deploy ${{ matrix.architecture }}
needs: information
runs-on: ubuntu-latest
strategy:
matrix:
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🏗 Set up build cache
id: cache
uses: actions/[email protected]
with:
path: /tmp/.docker-cache
key: docker-${{ matrix.architecture }}-${{ github.sha }}
restore-keys: |
docker-${{ matrix.architecture }}
- name: 🏗 Set up QEMU
uses: docker/[email protected]
- name: 🏗 Set up Docker Buildx
uses: docker/[email protected]
- name: ℹ️ Compose build flags
id: flags
run: |
echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
from=$(yq --no-colors eval ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}")
echo "from=${from}" >> "$GITHUB_OUTPUT"
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
echo "platform=linux/amd64" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
echo "platform=linux/386" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
echo "platform=linux/arm/v6" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
echo "platform=linux/arm/v7" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
echo "platform=linux/arm64/v8" >> "$GITHUB_OUTPUT"
else
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
exit 1
fi
- name: 🏗 Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ⤵️ Download base image
if: steps.flags.outputs.from != 'null'
run: docker pull "${{ steps.flags.outputs.from }}"
- name: 🚀 Build
uses: docker/[email protected]
with:
load: true
# yamllint disable rule:line-length
tags: |
ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}
ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}
# yamllint enable rule:line-length
context: ${{ needs.information.outputs.target }}
file: ${{ needs.information.outputs.target }}/Dockerfile
cache-from: |
type=local,src=/tmp/.docker-cache
ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge
cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new
platforms: ${{ steps.flags.outputs.platform }}
build-args: |
BUILD_ARCH=${{ matrix.architecture }}
BUILD_DATE=${{ steps.flags.outputs.date }}
BUILD_DESCRIPTION=${{ needs.information.outputs.description }}
BUILD_FROM=${{ steps.flags.outputs.from }}
BUILD_NAME=${{ needs.information.outputs.name }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ github.repository }}
BUILD_VERSION=${{ needs.information.outputs.version }}
# This ugly bit is necessary, or our cache will grow forever...
# Well until we hit GitHub's limit of 5GB :)
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Swap build cache
run: |
rm -rf /tmp/.docker-cache
mv /tmp/.docker-cache-new /tmp/.docker-cache
- name: 🚀 Push
# yamllint disable rule:line-length
run: |
docker push \
"ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}"
docker push \
"ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}"
publish-edge:
name: 📢 Publish to edge repository
if: needs.information.outputs.environment == 'edge'
needs:
- information
- deploy
environment:
name: ${{ needs.information.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: 🚀 Dispatch repository updater update signal
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ github.repository_owner }}/${{ inputs.repository_edge }}
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ needs.information.outputs.version }}"
}
publish-beta:
name: 📢 Publish to beta repository
if: |
needs.information.outputs.environment == 'beta' ||
needs.information.outputs.environment == 'stable'
needs:
- information
- deploy
environment:
name: ${{ needs.information.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: 🚀 Dispatch repository updater update signal
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ github.repository_owner }}/${{ inputs.repository_beta }}
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ github.event.release.tag_name }}"
}
publish-stable:
name: 📢 Publish to stable repository
if: needs.information.outputs.environment == 'stable'
needs:
- information
- deploy
environment:
name: ${{ needs.information.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: 🚀 Dispatch repository updater update signal
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ github.repository_owner }}/${{ inputs.repository }}
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ github.event.release.tag_name }}"
}
9 changes: 9 additions & 0 deletions .github/workflows/addon-main-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Draft release from new main push
on:
push:
branches:
- main

jobs:
workflows:
uses: Poeschl-HomeAssistant-Addons/workflows/.github/workflows/release-drafter.yaml@main
17 changes: 17 additions & 0 deletions .github/workflows/addon-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Check addon with linters
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
workflows:
uses: Poeschl-HomeAssistant-Addons/workflows/.github/workflows/addon-pr.yaml@main
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/data/options.json
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignored:
- DL3006
10 changes: 10 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
default: true

MD001: false # Heading levels should only increment by one level at a time
MD002: false # First header should be a h1 header
MD007: # Unordered list indentation
indent: 2
MD012: false # Multiple consecutive blank lines
MD013: false # Line length
MD025: false # Multiple top level headings in the same document
MD041: false # First line in file should be a top level header
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=SC2002
37 changes: 37 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
rules:
document-end:
level: error
present: false
document-start:
level: error
present: false
empty-lines:
level: error
max: 1
max-start: 0
max-end: 1
hyphens:
level: error
max-spaces-after: 1
indentation:
level: error
spaces: 2
indent-sequences: true
check-multi-line-strings: false
key-duplicates:
level: error
line-length:
level: warning
max: 180
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
new-line-at-end-of-file:
level: error
new-lines:
level: error
type: unix
trailing-spaces:
level: error
truthy:
level: error
Loading

0 comments on commit 01aa47b

Please sign in to comment.