Skip to content

Commit c7e5936

Browse files
eshattowE Shattow
authored andcommitted
introduce action.yml namespace output for conditional use of context repository_owner
Hard-coded "home-assistant" is now configurable and used as a fallback when the context github.repository_owner is not valid for the image to pull or run from.
1 parent 8cfef9e commit c7e5936

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

action.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: "Define the builder image archictecture (default: amd64)"
1414
required: false
1515
default: "amd64"
16+
namespace:
17+
description: "Define alternative namespace to use when image not found at this repository"
18+
required: true
19+
default: "home-assistant"
1620
runs:
1721
using: "composite"
1822
steps:
@@ -30,19 +34,29 @@ runs:
3034
fi
3135
echo "version=${input}" >> "$GITHUB_OUTPUT"
3236
37+
- shell: bash
38+
id: namespace
39+
run: |
40+
if docker manifest inspect ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}-builder:${{ steps.version.outputs.version }}
41+
then
42+
echo "namespace=${{ github.repository_owner }}" >> "$GITHUB_OUTPUT"
43+
else
44+
echo "namespace=${{ inputs.namespace }}" >> "$GITHUB_OUTPUT"
45+
fi
46+
3347
- shell: bash
3448
if: ${{ inputs.pull == 'true' }}
3549
run: |
36-
docker pull ghcr.io/home-assistant/${{ inputs.image }}-builder:${{ steps.version.outputs.version }}
50+
docker pull ghcr.io/${{ steps.namespace.outputs.namespace }}/${{ inputs.image }}-builder:${{ steps.version.outputs.version }}
3751
cosign verify \
3852
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
39-
--certificate-identity-regexp https://github.com/home-assistant/builder/.* \
40-
ghcr.io/home-assistant/${{ inputs.image }}-builder:${{ steps.version.outputs.version }}
53+
--certificate-identity-regexp https://github.com/${{ steps.namespace.outputs.namespace }}/builder/.* \
54+
ghcr.io/${{ steps.namespace.outputs.namespace }}/${{ inputs.image }}-builder:${{ steps.version.outputs.version }}
4155
4256
- shell: bash
4357
id: builder
4458
run: |
45-
builder=$(docker images ghcr.io/home-assistant/${{ inputs.image }}-builder:${{ steps.version.outputs.version }} -q)
59+
builder=$(docker images ghcr.io/${{ steps.namespace.outputs.namespace }}/${{ inputs.image }}-builder:${{ steps.version.outputs.version }} -q)
4660
echo "id=$builder" >> "$GITHUB_OUTPUT"
4761
4862
- shell: bash
@@ -59,7 +73,7 @@ runs:
5973
-v ~/.docker:/root/.docker \
6074
-v ${{ github.workspace }}:/data \
6175
--env-file "${{ github.action_path }}/env_file" \
62-
ghcr.io/home-assistant/${{ inputs.image }}-builder:${{ steps.version.outputs.version }} \
76+
ghcr.io/${{ steps.namespace.outputs.namespace }}/${{ inputs.image }}-builder:${{ steps.version.outputs.version }} \
6377
${{ inputs.args }}
6478
6579
sudo sysctl kernel.randomize_va_space=2

0 commit comments

Comments
 (0)