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:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
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:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
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
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -37,7 +48,7 @@ jobs:
|
|||||||
- name: Log in to registry
|
- name: Log in to registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ steps.registry.outputs.registry }}
|
||||||
username: ${{ vars.USERNAME }}
|
username: ${{ vars.USERNAME }}
|
||||||
password: ${{ secrets.PASS }}
|
password: ${{ secrets.PASS }}
|
||||||
|
|
||||||
@@ -45,7 +56,7 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ vars.USERNAME }}/${{ env.IMAGE_NAME }}
|
images: ${{ steps.registry.outputs.registry }}/${{ vars.USERNAME }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
# Only tag with version and latest on tag push
|
# Only tag with version and latest on tag push
|
||||||
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
|||||||
Reference in New Issue
Block a user