diff --git a/.gitea/workflows/docker-image.yml b/.gitea/workflows/docker-image.yml index 7163690..c3f4426 100644 --- a/.gitea/workflows/docker-image.yml +++ b/.gitea/workflows/docker-image.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: env: - IMAGE_NAME: wdw-sitemap-and-importer + LOCAL_IMAGE_NAME: wdw-sitemap-and-importer REGISTRY: ${{ secrets.REGISTRY_URL }} REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} @@ -20,10 +20,10 @@ jobs: uses: actions/checkout@v4 - name: Build image - run: docker build -t "${IMAGE_NAME}:${{ gitea.sha }}" . + run: docker build -t "${LOCAL_IMAGE_NAME}:${{ gitea.sha }}" . - name: Tag latest image - run: docker tag "${IMAGE_NAME}:${{ gitea.sha }}" "${IMAGE_NAME}:latest" + run: docker tag "${LOCAL_IMAGE_NAME}:${{ gitea.sha }}" "${LOCAL_IMAGE_NAME}:latest" - name: Log in and push image run: | @@ -33,10 +33,18 @@ jobs: exit 0 fi - echo "${REGISTRY_PASSWORD}" | docker login "${REGISTRY}" -u "${REGISTRY_USERNAME}" --password-stdin + REGISTRY_HOST="${REGISTRY#http://}" + REGISTRY_HOST="${REGISTRY_HOST#https://}" + REGISTRY_HOST="${REGISTRY_HOST%/}" + IMAGE_REPOSITORY="$(printf '%s' '${{ gitea.repository }}' | tr '[:upper:]' '[:lower:]')" + FULL_IMAGE="${REGISTRY_HOST}/${IMAGE_REPOSITORY}" - docker tag "${IMAGE_NAME}:${{ gitea.sha }}" "${REGISTRY}/${IMAGE_NAME}:${{ gitea.sha }}" - docker tag "${IMAGE_NAME}:latest" "${REGISTRY}/${IMAGE_NAME}:latest" + echo "Pushing image to ${FULL_IMAGE}" - docker push "${REGISTRY}/${IMAGE_NAME}:${{ gitea.sha }}" - docker push "${REGISTRY}/${IMAGE_NAME}:latest" + echo "${REGISTRY_PASSWORD}" | docker login "${REGISTRY_HOST}" -u "${REGISTRY_USERNAME}" --password-stdin + + docker tag "${LOCAL_IMAGE_NAME}:${{ gitea.sha }}" "${FULL_IMAGE}:${{ gitea.sha }}" + docker tag "${LOCAL_IMAGE_NAME}:latest" "${FULL_IMAGE}:latest" + + docker push "${FULL_IMAGE}:${{ gitea.sha }}" + docker push "${FULL_IMAGE}:latest" diff --git a/README.md b/README.md index 9915509..de221aa 100644 --- a/README.md +++ b/README.md @@ -98,8 +98,22 @@ The workflow always builds the Docker image. If these secrets are configured in Published tags: -- `${REGISTRY}/wdw-sitemap-and-importer:` -- `${REGISTRY}/wdw-sitemap-and-importer:latest` +- `${REGISTRY_URL}/wdw_internal_tools/wdw-sitemap-and-scraper-docker:` +- `${REGISTRY_URL}/wdw_internal_tools/wdw-sitemap-and-scraper-docker:latest` + +`REGISTRY_URL` should be the registry host only, for example: + +```text +registry.example.com +``` + +or: + +```text +gitea.example.com +``` + +Do not include `http://`, `https://`, or the repository path in `REGISTRY_URL`. The workflow derives the repository path from the Gitea repository name and converts it to lowercase for Docker compatibility. If the registry secrets are not configured, the workflow still performs the build as validation but skips the push steps.