Refactor registry handling in Docker workflow to use RUNNER_REGISTRY environment variable
Some checks failed
Build and publish Docker image / build-and-push (push) Failing after 3m46s
Some checks failed
Build and publish Docker image / build-and-push (push) Failing after 3m46s
Signed-off-by: Stephen Simpson <ssimpson89@users.noreply.github.com>
This commit is contained in:
@@ -15,16 +15,27 @@ env:
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
REGISTRY: ${{ runner.labels.filter(l => l.startsWith('registry=')).map(l => l.split('=')[1]).first() || 'gitea.sjs.io' }}
|
||||
container:
|
||||
image: gitea/runner-images:ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Get Registry
|
||||
id: registry
|
||||
run: |
|
||||
# Use RUNNER_REGISTRY environment variable
|
||||
if [ ! -z "${RUNNER_REGISTRY}" ]; then
|
||||
REGISTRY="${RUNNER_REGISTRY}"
|
||||
else
|
||||
echo "ERROR: RUNNER_REGISTRY environment variable not set"
|
||||
echo "Please add RUNNER_REGISTRY to your runner's environment variables"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "registry=${REGISTRY}" >> $GITHUB_OUTPUT
|
||||
echo "Using registry: ${REGISTRY}"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -37,7 +48,7 @@ jobs:
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
registry: ${{ steps.registry.outputs.registry }}
|
||||
username: ${{ vars.USERNAME }}
|
||||
password: ${{ secrets.PASS }}
|
||||
|
||||
@@ -45,7 +56,7 @@ jobs:
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ vars.USERNAME }}/${{ env.IMAGE_NAME }}
|
||||
images: ${{ steps.registry.outputs.registry }}/${{ vars.USERNAME }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
# Only tag with version and latest on tag push
|
||||
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
|
||||
Reference in New Issue
Block a user