mirror of
https://github.com/hassio-addons/addon-foldingathome.git
synced 2025-05-04 11:21:25 +00:00
🚀 Add-on to GitHub Actions (#11)
* 🚀 Add-on to GitHub Actions
* Prettified Code!
* Remove keep a changelog reference
* Adjust add-on linter errors
Co-authored-by: frenck <frenck@users.noreply.github.com>
This commit is contained in:
parent
db4e2e2433
commit
d34ec20fd1
20 changed files with 2719 additions and 109 deletions
260
.github/workflows/deploy.yaml
vendored
Normal file
260
.github/workflows/deploy.yaml
vendored
Normal file
|
@ -0,0 +1,260 @@
|
|||
---
|
||||
name: Deploy
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
workflow_run:
|
||||
workflows: ["CI"]
|
||||
branches: [main]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
information:
|
||||
if: |
|
||||
github.event_name == 'release'
|
||||
|| (
|
||||
github.event_name == 'workflow_run'
|
||||
&& github.event.workflow_run.conclusion == 'success'
|
||||
)
|
||||
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 }}
|
||||
environment: ${{ steps.release.outputs.environment }}
|
||||
name: ${{ steps.information.outputs.name }}
|
||||
slug: ${{ steps.information.outputs.slug }}
|
||||
target: ${{ steps.information.outputs.target }}
|
||||
version: ${{ steps.release.outputs.version }}
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.3.4
|
||||
- name: 🚀 Run add-on information action
|
||||
id: information
|
||||
uses: frenck/action-addon-information@v1.2.2
|
||||
- name: ℹ️ Gather version and environment
|
||||
id: release
|
||||
run: |
|
||||
sha="${{ github.sha }}"
|
||||
environment="edge"
|
||||
version="${sha:0:7}"
|
||||
if [[ "${{ github.event_name }}" = "release" ]]; then
|
||||
version="${{ github.event.release.tag_name }}"
|
||||
version="${version,,}"
|
||||
version="${version#v}"
|
||||
environment="stable"
|
||||
if [[ "${{ github.event.release.prerelease }}" = "true" ]]; then
|
||||
environment="beta"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "::set-output name=environment::${environment}"
|
||||
echo "::set-output name=version::${version}"
|
||||
|
||||
deploy:
|
||||
name: 👷 Build & Deploy ${{ matrix.architecture }}
|
||||
needs: information
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
|
||||
steps:
|
||||
- name: 🔂 Wait for other runs to complete
|
||||
uses: softprops/turnstyle@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.3.4
|
||||
- name: 🏗 Set up build cache
|
||||
id: cache
|
||||
uses: actions/cache@v2.1.6
|
||||
with:
|
||||
path: /tmp/.docker-cache
|
||||
key: docker-${{ matrix.architecture }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
docker-${{ matrix.architecture }}
|
||||
- name: 🏗 Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
- name: 🏗 Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1.5.1
|
||||
- name: 🏗 Set up CodeNotary
|
||||
run: bash <(curl https://getvcn.codenotary.com -L)
|
||||
- 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: 🏗 Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1.10.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: ⤵️ Download base image
|
||||
run: docker pull "${{ steps.flags.outputs.from }}"
|
||||
- name: ✅ Verify authenticity of base image
|
||||
run: |
|
||||
vcn authenticate \
|
||||
"docker://${{ steps.flags.outputs.from }}"
|
||||
vcn authenticate \
|
||||
--output json \
|
||||
--signerID 0x03e406879fd89e52f38f4aab0061266d1183980a \
|
||||
"docker://${{ steps.flags.outputs.from }}" \
|
||||
| jq \
|
||||
--exit-status \
|
||||
'.verification.status == 0'
|
||||
- name: 🚀 Build
|
||||
uses: docker/build-push-action@v2.6.1
|
||||
with:
|
||||
load: true
|
||||
# yamllint disable rule:line-length
|
||||
tags: |
|
||||
ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}
|
||||
ghcr.io/hassio-addons/${{ 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/hassio-addons/${{ 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: 🔏 Notarize
|
||||
# yamllint disable rule:line-length
|
||||
run: |
|
||||
if vcn authenticate \
|
||||
--output json \
|
||||
"docker://ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}" \
|
||||
| jq \
|
||||
--exit-status \
|
||||
'.verification.status != 0';
|
||||
then
|
||||
vcn login
|
||||
vcn notarize \
|
||||
--public \
|
||||
"docker://ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}"
|
||||
fi
|
||||
env:
|
||||
VCN_USER: ${{ secrets.VCN_USER }}
|
||||
VCN_PASSWORD: ${{ secrets.VCN_PASSWORD }}
|
||||
VCN_NOTARIZATION_PASSWORD: ${{ secrets.VCN_NOTARIZATION_PASSWORD }}
|
||||
VCN_OTP_EMPTY: true
|
||||
- name: 🚀 Push
|
||||
# yamllint disable rule:line-length
|
||||
run: |
|
||||
docker push \
|
||||
"ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}"
|
||||
docker push \
|
||||
"ghcr.io/hassio-addons/${{ 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/repository-dispatch@v1.1.3
|
||||
with:
|
||||
token: ${{ secrets.DISPATCH_TOKEN }}
|
||||
repository: hassio-addons/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/repository-dispatch@v1.1.3
|
||||
with:
|
||||
token: ${{ secrets.DISPATCH_TOKEN }}
|
||||
repository: hassio-addons/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/repository-dispatch@v1.1.3
|
||||
with:
|
||||
token: ${{ secrets.DISPATCH_TOKEN }}
|
||||
repository: hassio-addons/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 }}"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue