This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -98,8 +98,22 @@ The workflow always builds the Docker image. If these secrets are configured in
|
||||
|
||||
Published tags:
|
||||
|
||||
- `${REGISTRY}/wdw-sitemap-and-importer:<commit-sha>`
|
||||
- `${REGISTRY}/wdw-sitemap-and-importer:latest`
|
||||
- `${REGISTRY_URL}/wdw_internal_tools/wdw-sitemap-and-scraper-docker:<commit-sha>`
|
||||
- `${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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user