Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Commit

Permalink
Add new repository workflow (#26)
Browse files Browse the repository at this point in the history
* Add new repository workflow

* Prettified Code!

* Address add-on lint errors

* Migrate Docker build arguments

* Documentation tweaks

Co-authored-by: frenck <[email protected]>
  • Loading branch information
frenck and frenck authored Jan 22, 2021
1 parent cedde45 commit b79c2c2
Show file tree
Hide file tree
Showing 19 changed files with 9,505 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

> ([Github link][autolink-references] to related issues or pull requests)
[autolink-references]: https://help.github.com/articles/autolinked-references-and-urls/
[autolink-references]: https://help.github.com/articles/autolinked-references-and-urls/
8 changes: 8 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "06:00"
85 changes: 85 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
- name: "breaking-change"
color: ee0701
description: "A breaking change for existing users."
- name: "bugfix"
color: ee0701
description: "Inconsistencies or issues which will cause a problem for users or implementors."
- name: "documentation"
color: 0052cc
description: "Solely about the documentation of the project."
- name: "enhancement"
color: 1d76db
description: "Enhancement of the code, not introducing new features."
- name: "refactor"
color: 1d76db
description: "Improvement of existing code, not introducing new features."
- name: "performance"
color: 1d76db
description: "Improving performance, not introducing new features."
- name: "new-feature"
color: 0e8a16
description: "New features or options."
- name: "maintenance"
color: 2af79e
description: "Generic maintenance tasks."
- name: "ci"
color: 1d76db
description: "Work that improves the continue integration."
- name: "dependencies"
color: 1d76db
description: "Upgrade or downgrade of project dependencies."

- name: "in-progress"
color: fbca04
description: "Issue is currently being resolved by a developer."
- name: "stale"
color: fef2c0
description: "There has not been activity on this issue or PR for quite some time."
- name: "no-stale"
color: fef2c0
description: "This issue or PR is exempted from the stable bot."

- name: "security"
color: ee0701
description: "Marks a security issue that needs to be resolved asap."
- name: "incomplete"
color: fef2c0
description: "Marks a PR or issue that is missing information."
- name: "invalid"
color: fef2c0
description: "Marks a PR or issue that is missing information."

- name: "beginner-friendly"
color: 0e8a16
description: "Good first issue for people wanting to contribute to the project."
- name: "help-wanted"
color: 0e8a16
description: "We need some extra helping hands or expertise in order to resolve this."

- name: "hacktoberfest"
description: "Issues/PRs are participating in the Hacktoberfest."
color: fbca04
- name: "hacktoberfest-accepted"
description: "Issues/PRs are participating in the Hacktoberfest."
color: fbca04

- name: "priority-critical"
color: ee0701
description: "This should be dealt with ASAP. Not fixing this issue would be a serious error."
- name: "priority-high"
color: b60205
description: "After critical issues are fixed, these should be dealt with before any further issues."
- name: "priority-medium"
color: 0e8a16
description: "This issue may be useful, and needs some attention."
- name: "priority-low"
color: e4ea8a
description: "Nice addition, maybe... someday..."

- name: "major"
color: b60205
description: "This PR causes a major version bump in the version number."
- name: "minor"
color: 0e8a16
description: "This PR causes a minor version bump in the version number."
57 changes: 57 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
sort-direction: ascending

categories:
- title: "🚨 Breaking changes"
labels:
- "breaking-change"
- title: "✨ New features"
labels:
- "new-feature"
- title: "🐛 Bug fixes"
labels:
- "bugfix"
- title: "🚀 Enhancements"
labels:
- "enhancement"
- "refactor"
- "performance"
- title: "🧰 Maintenance"
labels:
- "maintenance"
- "ci"
- title: "📚 Documentation"
labels:
- "documentation"
- title: "⬆️ Dependency updates"
labels:
- "dependencies"

version-resolver:
major:
labels:
- "major"
- "breaking-change"
minor:
labels:
- "minor"
- "new-feature"
patch:
labels:
- "bugfix"
- "chore"
- "ci"
- "dependencies"
- "documentation"
- "enhancement"
- "performance"
- "refactor"
default: patch

template: |
## What’s changed
$CHANGES
182 changes: 182 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
name: CI

# yamllint disable-line rule:truthy
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

jobs:
information:
name: Gather add-on information
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.information.outputs.architectures }}
build: ${{ steps.information.outputs.build }}
description: ${{ steps.information.outputs.description }}
name: ${{ steps.information.outputs.name }}
slug: ${{ steps.information.outputs.slug }}
target: ${{ steps.information.outputs.target }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run add-on information action
id: information
uses: frenck/[email protected]

lint-addon:
name: Lint Add-on
needs:
- information
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run Add-on Lint
uses: frenck/[email protected]
with:
community: true
path: "./${{ needs.information.outputs.target }}"

lint-hadolint:
name: Hadolint
needs:
- information
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run Hadolint
uses: brpaz/[email protected]
with:
dockerfile: "./${{ needs.information.outputs.target }}/Dockerfile"

lint-json:
name: JSON Lint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run JQ
run: |
shopt -s globstar
cat **/*.json | jq '.'
lint-markdown:
name: MarkdownLint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run mdl
uses: actionshub/[email protected]

lint-shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run Shellcheck
uses: ludeeus/[email protected]
env:
SHELLCHECK_OPTS: -s bash

lint-yamllint:
name: YAMLLint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run YAMLLint
uses: frenck/[email protected]

lint-prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🚀 Run Prettier
uses: creyD/[email protected]
with:
prettier_options: --write **/*.{json,js,md,yaml}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build:
name: Build ${{ matrix.architecture }}
needs:
- information
- lint-addon
- lint-hadolint
- lint-json
- lint-markdown
- lint-prettier
- lint-shellcheck
- lint-yamllint
runs-on: ubuntu-latest
strategy:
matrix:
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
- name: 🏗 Set up build cache
id: cache
uses: actions/[email protected]
with:
path: /tmp/.docker-cache
key: docker-${{ github.ref }}-${{ matrix.architecture }}-${{ github.sha }}
restore-keys: |
docker-${{ github.ref }}-${{ 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 "::set-output name=date::$(date +"%Y-%m-%dT%H:%M:%SZ")"
from=$(jq --raw-output ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}")
echo "::set-output name=from::${from}"
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
echo "::set-output name=platform::linux/amd64"
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
echo "::set-output name=platform::linux/386"
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
echo "::set-output name=platform::linux/arm/v6"
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
echo "::set-output name=platform::linux/arm/v7"
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
echo "::set-output name=platform::linux/arm64/v8"
else
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
exit 1
fi
- name: 🚀 Build
uses: docker/[email protected]
with:
push: false
context: ${{ needs.information.outputs.target }}
file: ${{ needs.information.outputs.target }}/Dockerfile
cache-from: |
type=local,src=/tmp/.docker-cache
ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge
cache-to: type=local,mode=max,dest=/tmp/.docker-cache
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=edge
Loading

0 comments on commit b79c2c2

Please sign in to comment.