-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from TECH7Fox/stand-docker
Allow to run as a standalone Docker container
- Loading branch information
Showing
24 changed files
with
264 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github: [TECH7Fox] | ||
github: [TECH7Fox, felipecrs] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,65 @@ | ||
name: Builder | ||
|
||
env: | ||
BUILD_ARGS: "" | ||
MONITORED_FILES: "build.yaml config.yaml Dockerfile rootfs" | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- "main" | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
init: | ||
runs-on: ubuntu-latest | ||
name: Initialize builds | ||
outputs: | ||
changed_addons: ${{ steps.changed_addons.outputs.addons }} | ||
changed: ${{ steps.changed_addons.outputs.changed }} | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
- "main" | ||
|
||
- name: Get changed files | ||
id: changed_files | ||
uses: jitterbit/get-changed-files@v1 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
- name: Find add-on directories | ||
id: addons | ||
uses: home-assistant/actions/helpers/find-addons@master | ||
|
||
- name: Get changed add-ons | ||
id: changed_addons | ||
run: | | ||
declare -a changed_addons | ||
for addon in ${{ steps.addons.outputs.addons }}; do | ||
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then | ||
for file in ${{ env.MONITORED_FILES }}; do | ||
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then | ||
if [[ ! "${changed_addons[@]}" =~ $addon ]]; then | ||
changed_addons+=("\"${addon}\","); | ||
fi | ||
fi | ||
done | ||
fi | ||
done | ||
changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) | ||
if [[ -n ${changed} ]]; then | ||
echo "Changed add-ons: $changed"; | ||
echo "::set-output name=changed::true"; | ||
echo "::set-output name=addons::[$changed]"; | ||
else | ||
echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"; | ||
fi | ||
build: | ||
needs: init | ||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
if: needs.init.outputs.changed == 'true' | ||
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
addon: ${{ fromJson(needs.init.outputs.changed_addons) }} | ||
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] | ||
|
||
steps: | ||
- name: Check out repository | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get information | ||
id: info | ||
uses: home-assistant/actions/helpers/info@master | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Get lowercase GitHub username | ||
id: repository_owner | ||
uses: ASzc/change-string-case-action@v5 | ||
with: | ||
path: "./${{ matrix.addon }}" | ||
|
||
- name: Check if add-on should be built | ||
id: check | ||
run: | | ||
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then | ||
echo "::set-output name=build_arch::true"; | ||
echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)"; | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
echo "BUILD_ARGS=--version pr-${{ github.event.number }}" >> $GITHUB_ENV; | ||
fi | ||
else | ||
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; | ||
echo "::set-output name=build_arch::false"; | ||
fi | ||
string: ${{ github.repository_owner }} | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/asterisk-hass-addon | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
- name: Login to GitHub Container Registry | ||
- name: Login to DockerHub | ||
if: github.event_name == 'push' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get lowercase GitHub username | ||
id: repository_owner | ||
uses: ASzc/change-string-case-action@v5 | ||
with: | ||
string: ${{ github.repository_owner }} | ||
|
||
- name: Build ${{ matrix.addon }} add-on | ||
if: steps.check.outputs.build_arch == 'true' | ||
uses: home-assistant/builder@2023.03.0 | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
args: | | ||
${{ env.BUILD_ARGS }} \ | ||
--${{ matrix.arch }} \ | ||
--target /data/${{ matrix.addon }} \ | ||
--image "${{ steps.check.outputs.image }}" \ | ||
--docker-hub "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}" \ | ||
--addon | ||
context: asterisk | ||
platforms: | | ||
linux/amd64 | ||
linux/386 | ||
linux/arm/v6 | ||
linux/arm/v7 | ||
linux/arm64 | ||
push: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
find: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/config/* | ||
!/config/.gitkeep | ||
|
||
/media/* | ||
!/media/.gitkeep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
build_from: | ||
aarch64: ghcr.io/hassio-addons/debian-base/aarch64:6.2.3 | ||
amd64: ghcr.io/hassio-addons/debian-base/amd64:6.2.3 | ||
armhf: ghcr.io/hassio-addons/debian-base/armhf:6.2.3 | ||
armv7: ghcr.io/hassio-addons/debian-base/armv7:6.2.3 | ||
i386: ghcr.io/hassio-addons/debian-base/i386:6.2.3 | ||
labels: | ||
org.opencontainers.image.title: "Home Assistant Add-on: Asterisk" | ||
org.opencontainers.image.description: "PBX server for SIP devices like doorbells and phones." | ||
org.opencontainers.image.source: "https://github.com/TECH7Fox/asterisk-hass-addons" | ||
org.opencontainers.image.licenses: "MIT" | ||
aarch64: ghcr.io/hassio-addons/debian-base:6.2.3 | ||
amd64: ghcr.io/hassio-addons/debian-base:6.2.3 | ||
armhf: ghcr.io/hassio-addons/debian-base:6.2.3 | ||
armv7: ghcr.io/hassio-addons/debian-base:6.2.3 | ||
i386: ghcr.io/hassio-addons/debian-base:6.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.