Skip to content

Commit f13b32b

Browse files
authored
Add new repository workflow (#22)
* Add new repository workflow * Prettified Code! * Migrate Docker build arguments * Address add-on lint errors * Documentation tweaks Co-authored-by: frenck <frenck@users.noreply.github.com>
1 parent 7ca1bdb commit f13b32b

16 files changed

Lines changed: 662 additions & 28 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
> ([Github link][autolink-references] to related issues or pull requests)
88
9-
[autolink-references]: https://help.github.com/articles/autolinked-references-and-urls/
9+
[autolink-references]: https://help.github.com/articles/autolinked-references-and-urls/

.github/dependabot.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: daily
8+
time: "06:00"

.github/labels.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
- name: "breaking-change"
3+
color: ee0701
4+
description: "A breaking change for existing users."
5+
- name: "bugfix"
6+
color: ee0701
7+
description: "Inconsistencies or issues which will cause a problem for users or implementors."
8+
- name: "documentation"
9+
color: 0052cc
10+
description: "Solely about the documentation of the project."
11+
- name: "enhancement"
12+
color: 1d76db
13+
description: "Enhancement of the code, not introducing new features."
14+
- name: "refactor"
15+
color: 1d76db
16+
description: "Improvement of existing code, not introducing new features."
17+
- name: "performance"
18+
color: 1d76db
19+
description: "Improving performance, not introducing new features."
20+
- name: "new-feature"
21+
color: 0e8a16
22+
description: "New features or options."
23+
- name: "maintenance"
24+
color: 2af79e
25+
description: "Generic maintenance tasks."
26+
- name: "ci"
27+
color: 1d76db
28+
description: "Work that improves the continue integration."
29+
- name: "dependencies"
30+
color: 1d76db
31+
description: "Upgrade or downgrade of project dependencies."
32+
33+
- name: "in-progress"
34+
color: fbca04
35+
description: "Issue is currently being resolved by a developer."
36+
- name: "stale"
37+
color: fef2c0
38+
description: "There has not been activity on this issue or PR for quite some time."
39+
- name: "no-stale"
40+
color: fef2c0
41+
description: "This issue or PR is exempted from the stable bot."
42+
43+
- name: "security"
44+
color: ee0701
45+
description: "Marks a security issue that needs to be resolved asap."
46+
- name: "incomplete"
47+
color: fef2c0
48+
description: "Marks a PR or issue that is missing information."
49+
- name: "invalid"
50+
color: fef2c0
51+
description: "Marks a PR or issue that is missing information."
52+
53+
- name: "beginner-friendly"
54+
color: 0e8a16
55+
description: "Good first issue for people wanting to contribute to the project."
56+
- name: "help-wanted"
57+
color: 0e8a16
58+
description: "We need some extra helping hands or expertise in order to resolve this."
59+
60+
- name: "hacktoberfest"
61+
description: "Issues/PRs are participating in the Hacktoberfest."
62+
color: fbca04
63+
- name: "hacktoberfest-accepted"
64+
description: "Issues/PRs are participating in the Hacktoberfest."
65+
color: fbca04
66+
67+
- name: "priority-critical"
68+
color: ee0701
69+
description: "This should be dealt with ASAP. Not fixing this issue would be a serious error."
70+
- name: "priority-high"
71+
color: b60205
72+
description: "After critical issues are fixed, these should be dealt with before any further issues."
73+
- name: "priority-medium"
74+
color: 0e8a16
75+
description: "This issue may be useful, and needs some attention."
76+
- name: "priority-low"
77+
color: e4ea8a
78+
description: "Nice addition, maybe... someday..."
79+
80+
- name: "major"
81+
color: b60205
82+
description: "This PR causes a major version bump in the version number."
83+
- name: "minor"
84+
color: 0e8a16
85+
description: "This PR causes a minor version bump in the version number."

.github/release-drafter.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name-template: "v$RESOLVED_VERSION"
3+
tag-template: "v$RESOLVED_VERSION"
4+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
5+
sort-direction: ascending
6+
7+
categories:
8+
- title: "🚨 Breaking changes"
9+
labels:
10+
- "breaking-change"
11+
- title: "✨ New features"
12+
labels:
13+
- "new-feature"
14+
- title: "🐛 Bug fixes"
15+
labels:
16+
- "bugfix"
17+
- title: "🚀 Enhancements"
18+
labels:
19+
- "enhancement"
20+
- "refactor"
21+
- "performance"
22+
- title: "🧰 Maintenance"
23+
labels:
24+
- "maintenance"
25+
- "ci"
26+
- title: "📚 Documentation"
27+
labels:
28+
- "documentation"
29+
- title: "⬆️ Dependency updates"
30+
labels:
31+
- "dependencies"
32+
33+
version-resolver:
34+
major:
35+
labels:
36+
- "major"
37+
- "breaking-change"
38+
minor:
39+
labels:
40+
- "minor"
41+
- "new-feature"
42+
patch:
43+
labels:
44+
- "bugfix"
45+
- "chore"
46+
- "ci"
47+
- "dependencies"
48+
- "documentation"
49+
- "enhancement"
50+
- "performance"
51+
- "refactor"
52+
default: patch
53+
54+
template: |
55+
## What’s changed
56+
57+
$CHANGES

.github/workflows/ci.yaml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
name: CI
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
push:
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
workflow_dispatch:
13+
14+
jobs:
15+
information:
16+
name: Gather add-on information
17+
runs-on: ubuntu-latest
18+
outputs:
19+
architectures: ${{ steps.information.outputs.architectures }}
20+
build: ${{ steps.information.outputs.build }}
21+
description: ${{ steps.information.outputs.description }}
22+
name: ${{ steps.information.outputs.name }}
23+
slug: ${{ steps.information.outputs.slug }}
24+
target: ${{ steps.information.outputs.target }}
25+
steps:
26+
- name: ⤵️ Check out code from GitHub
27+
uses: actions/checkout@v2.3.4
28+
- name: 🚀 Run add-on information action
29+
id: information
30+
uses: frenck/action-addon-information@v1.0.0
31+
32+
lint-addon:
33+
name: Lint Add-on
34+
needs:
35+
- information
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: ⤵️ Check out code from GitHub
39+
uses: actions/checkout@v2.3.4
40+
- name: 🚀 Run Add-on Lint
41+
uses: frenck/action-addon-linter@v1.3.1
42+
with:
43+
community: true
44+
path: "./${{ needs.information.outputs.target }}"
45+
46+
lint-hadolint:
47+
name: Hadolint
48+
needs:
49+
- information
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: ⤵️ Check out code from GitHub
53+
uses: actions/checkout@v2.3.4
54+
- name: 🚀 Run Hadolint
55+
uses: brpaz/hadolint-action@v1.3.1
56+
with:
57+
dockerfile: "./${{ needs.information.outputs.target }}/Dockerfile"
58+
59+
lint-json:
60+
name: JSON Lint
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: ⤵️ Check out code from GitHub
64+
uses: actions/checkout@v2.3.4
65+
- name: 🚀 Run JQ
66+
run: |
67+
shopt -s globstar
68+
cat **/*.json | jq '.'
69+
70+
lint-markdown:
71+
name: MarkdownLint
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: ⤵️ Check out code from GitHub
75+
uses: actions/checkout@v2.3.4
76+
- name: 🚀 Run mdl
77+
uses: actionshub/markdownlint@2.0.0
78+
79+
lint-shellcheck:
80+
name: Shellcheck
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: ⤵️ Check out code from GitHub
84+
uses: actions/checkout@v2.3.4
85+
- name: 🚀 Run Shellcheck
86+
uses: ludeeus/action-shellcheck@1.0.0
87+
env:
88+
SHELLCHECK_OPTS: -s bash
89+
90+
lint-yamllint:
91+
name: YAMLLint
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: ⤵️ Check out code from GitHub
95+
uses: actions/checkout@v2.3.4
96+
- name: 🚀 Run YAMLLint
97+
uses: frenck/action-yamllint@v1.0.2
98+
99+
lint-prettier:
100+
name: Prettier
101+
runs-on: ubuntu-latest
102+
steps:
103+
- name: ⤵️ Check out code from GitHub
104+
uses: actions/checkout@v2.3.4
105+
- name: 🚀 Run Prettier
106+
uses: creyD/prettier_action@v3.3
107+
with:
108+
prettier_options: --write **/*.{json,js,md,yaml}
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
112+
build:
113+
name: Build ${{ matrix.architecture }}
114+
needs:
115+
- information
116+
- lint-addon
117+
- lint-hadolint
118+
- lint-json
119+
- lint-markdown
120+
- lint-prettier
121+
- lint-shellcheck
122+
- lint-yamllint
123+
runs-on: ubuntu-latest
124+
strategy:
125+
matrix:
126+
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
127+
steps:
128+
- name: ⤵️ Check out code from GitHub
129+
uses: actions/checkout@v2.3.4
130+
- name: 🏗 Set up build cache
131+
id: cache
132+
uses: actions/cache@v2.1.3
133+
with:
134+
path: /tmp/.docker-cache
135+
key: docker-${{ github.ref }}-${{ matrix.architecture }}-${{ github.sha }}
136+
restore-keys: |
137+
docker-${{ github.ref }}-${{ matrix.architecture }}
138+
- name: 🏗 Set up QEMU
139+
uses: docker/setup-qemu-action@v1.0.1
140+
- name: 🏗 Set up Docker Buildx
141+
uses: docker/setup-buildx-action@v1.1.1
142+
- name: ℹ️ Compose build flags
143+
id: flags
144+
run: |
145+
echo "::set-output name=date::$(date +"%Y-%m-%dT%H:%M:%SZ")"
146+
from=$(jq --raw-output ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}")
147+
echo "::set-output name=from::${from}"
148+
149+
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
150+
echo "::set-output name=platform::linux/amd64"
151+
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
152+
echo "::set-output name=platform::linux/386"
153+
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
154+
echo "::set-output name=platform::linux/arm/v6"
155+
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
156+
echo "::set-output name=platform::linux/arm/v7"
157+
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
158+
echo "::set-output name=platform::linux/arm64/v8"
159+
else
160+
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
161+
exit 1
162+
fi
163+
- name: 🚀 Build
164+
uses: docker/build-push-action@v2.2.2
165+
with:
166+
push: false
167+
context: ${{ needs.information.outputs.target }}
168+
file: ${{ needs.information.outputs.target }}/Dockerfile
169+
cache-from: |
170+
type=local,src=/tmp/.docker-cache
171+
ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge
172+
cache-to: type=local,mode=max,dest=/tmp/.docker-cache
173+
platforms: ${{ steps.flags.outputs.platform }}
174+
build-args: |
175+
BUILD_ARCH=${{ matrix.architecture }}
176+
BUILD_DATE=${{ steps.flags.outputs.date }}
177+
BUILD_DESCRIPTION=${{ needs.information.outputs.description }}
178+
BUILD_FROM=${{ steps.flags.outputs.from }}
179+
BUILD_NAME=${{ needs.information.outputs.name }}
180+
BUILD_REF=${{ github.sha }}
181+
BUILD_REPOSITORY=${{ github.repository }}
182+
BUILD_VERSION=edge

0 commit comments

Comments
 (0)