diff --git a/.builder/action.yml b/.builder/action.yml new file mode 100644 index 000000000..04ae20766 --- /dev/null +++ b/.builder/action.yml @@ -0,0 +1,68 @@ +name: "Home Assistant builder" +description: "Multi-purpose cross-compile docker builder" +inputs: + args: + description: "Arguments passed to the builder" + required: true + default: "--help" +runs: + using: "composite" + steps: + - shell: bash + id: version + run: | + input=$(echo "${{ github.action_path }}" | cut -d"/" -f8 ) + if [[ "${input}" == "master" ]] || [[ -z "${input}" ]]; then + input="latest" + fi + echo "::set-output name=version::${input}" + + - uses: home-assistant/actions/helpers/cas@master + + - shell: bash + run: | + docker pull ghcr.io/home-assistant/amd64-builder:${{ steps.version.outputs.version }} + + - shell: bash + run: | + for j in {1..15}; do + if CAS_API_KEY= cas authenticate --silent --signerID notary@home-assistant.io docker://ghcr.io/home-assistant/amd64-builder:${{ steps.version.outputs.version }}; then + exit 0 + fi + sleep $((5 * j)) + done + + echo "Invalid signature!" + exit 1 + + - shell: bash + id: builder + run: | + builder=$(docker images ghcr.io/home-assistant/amd64-builder:${{ steps.version.outputs.version }} -q) + echo "::set-output name=id::$builder" + + - shell: bash + id: build + run: | + env > "${{ github.action_path }}/env_file" + sed -i "/\(HOME\|TERM\|PWD\|HOSTNAME\|PATH\|SHLVL\|USER\|GOROOT\)/d" "${{ github.action_path }}/env_file" + + docker run --rm --privileged \ + -v /var/run/docker.sock:/var/run/docker.sock:ro \ + -v ~/.docker:/root/.docker \ + -v ${{ github.workspace }}:/data \ + --env-file "${{ github.action_path }}/env_file" \ + ghcr.io/home-assistant/amd64-builder:${{ steps.version.outputs.version }} \ + ${{ inputs.args }} + + - shell: bash + id: verify + run: | + docker images \ + --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" \ + --filter reference="*/*" \ + --filter reference="*" \ + --filter since=${{ steps.builder.outputs.id }} +branding: + icon: "home" + color: "blue"