merge develop to main #13
@@ -69,6 +69,9 @@ jobs:
|
|||||||
if [ -n "${server_host}" ] && ! printf '%s' "${registry_host}" | grep -qi "${server_host}"; then
|
if [ -n "${server_host}" ] && ! printf '%s' "${registry_host}" | grep -qi "${server_host}"; then
|
||||||
echo "::warning::REGISTRY_URL (${REGISTRY_URL}) does not match current Gitea host (${server_host}). Ensure this registry endpoint is managed by Gitea." >&2
|
echo "::warning::REGISTRY_URL (${REGISTRY_URL}) does not match current Gitea host (${server_host}). Ensure this registry endpoint is managed by Gitea." >&2
|
||||||
fi
|
fi
|
||||||
|
registry_repository="${registry_host}/allucanget/${REGISTRY_CONTAINER_NAME}"
|
||||||
|
echo "REGISTRY_HOST=${registry_host}" >> "$GITHUB_ENV"
|
||||||
|
echo "REGISTRY_REPOSITORY=${registry_repository}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Set up QEMU and Buildx
|
- name: Set up QEMU and Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -76,27 +79,26 @@ jobs:
|
|||||||
- name: Log in to gitea registry
|
- name: Log in to gitea registry
|
||||||
if: ${{ steps.meta.outputs.allow_push == 'true' }}
|
if: ${{ steps.meta.outputs.allow_push == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
continue-on-error: true
|
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY_URL }}
|
registry: ${{ env.REGISTRY_HOST }}
|
||||||
username: ${{ env.REGISTRY_USERNAME }}
|
username: ${{ env.REGISTRY_USERNAME }}
|
||||||
password: ${{ env.REGISTRY_PASSWORD }}
|
password: ${{ env.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
id: build-image
|
id: build-image
|
||||||
env:
|
env:
|
||||||
REGISTRY_URL: ${{ env.REGISTRY_URL }}
|
REGISTRY_REPOSITORY: ${{ env.REGISTRY_REPOSITORY }}
|
||||||
REGISTRY_CONTAINER_NAME: ${{ env.REGISTRY_CONTAINER_NAME }}
|
REGISTRY_CONTAINER_NAME: ${{ env.REGISTRY_CONTAINER_NAME }}
|
||||||
SHA_TAG: ${{ steps.meta.outputs.sha }}
|
SHA_TAG: ${{ steps.meta.outputs.sha }}
|
||||||
PUSH_IMAGE: ${{ steps.meta.outputs.allow_push == 'true' && env.REGISTRY_URL != '' && env.REGISTRY_USERNAME != '' && env.REGISTRY_PASSWORD != '' }}
|
PUSH_IMAGE: ${{ steps.meta.outputs.allow_push == 'true' && env.REGISTRY_HOST != '' && env.REGISTRY_USERNAME != '' && env.REGISTRY_PASSWORD != '' }}
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
LOG_FILE=build.log
|
LOG_FILE=build.log
|
||||||
if [ "${PUSH_IMAGE}" = "true" ]; then
|
if [ "${PUSH_IMAGE}" = "true" ]; then
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--push \
|
--load \
|
||||||
--tag "${REGISTRY_URL}/allucanget/${REGISTRY_CONTAINER_NAME}:latest" \
|
--tag "${REGISTRY_REPOSITORY}:latest" \
|
||||||
--tag "${REGISTRY_URL}/allucanget/${REGISTRY_CONTAINER_NAME}:${SHA_TAG}" \
|
--tag "${REGISTRY_REPOSITORY}:${SHA_TAG}" \
|
||||||
--file Dockerfile \
|
--file Dockerfile \
|
||||||
. 2>&1 | tee "${LOG_FILE}"
|
. 2>&1 | tee "${LOG_FILE}"
|
||||||
else
|
else
|
||||||
@@ -107,6 +109,20 @@ jobs:
|
|||||||
. 2>&1 | tee "${LOG_FILE}"
|
. 2>&1 | tee "${LOG_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Push image
|
||||||
|
if: ${{ steps.meta.outputs.allow_push == 'true' }}
|
||||||
|
env:
|
||||||
|
REGISTRY_REPOSITORY: ${{ env.REGISTRY_REPOSITORY }}
|
||||||
|
SHA_TAG: ${{ steps.meta.outputs.sha }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${REGISTRY_REPOSITORY}" ]; then
|
||||||
|
echo "::error::REGISTRY_REPOSITORY not defined; cannot push image" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
docker push "${REGISTRY_REPOSITORY}:${SHA_TAG}"
|
||||||
|
docker push "${REGISTRY_REPOSITORY}:latest"
|
||||||
|
|
||||||
- name: Upload docker build logs
|
- name: Upload docker build logs
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -128,6 +144,21 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Resolve registry repository
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${REGISTRY_URL}" ]; then
|
||||||
|
echo "::error::REGISTRY_URL secret not configured. Configure it with your Gitea container registry host." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
registry_host="${REGISTRY_URL#http://}"
|
||||||
|
registry_host="${registry_host#https://}"
|
||||||
|
registry_host="${registry_host%%/*}"
|
||||||
|
registry_host="${registry_host%%:*}"
|
||||||
|
registry_repository="${registry_host}/allucanget/${REGISTRY_CONTAINER_NAME}"
|
||||||
|
echo "REGISTRY_HOST=${registry_host}" >> "$GITHUB_ENV"
|
||||||
|
echo "REGISTRY_REPOSITORY=${registry_repository}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Capture commit metadata
|
- name: Capture commit metadata
|
||||||
id: commit_meta
|
id: commit_meta
|
||||||
run: |
|
run: |
|
||||||
@@ -152,7 +183,7 @@ jobs:
|
|||||||
- name: Deploy to staging
|
- name: Deploy to staging
|
||||||
if: contains(steps.commit_meta.outputs.message, '[deploy staging]')
|
if: contains(steps.commit_meta.outputs.message, '[deploy staging]')
|
||||||
run: |
|
run: |
|
||||||
kubectl set image deployment/calminer-app calminer=${REGISTRY_URL}/allucanget/${REGISTRY_CONTAINER_NAME}:latest
|
kubectl set image deployment/calminer-app calminer=${REGISTRY_REPOSITORY}:latest
|
||||||
kubectl apply -f k8s/configmap.yaml
|
kubectl apply -f k8s/configmap.yaml
|
||||||
kubectl apply -f k8s/secret.yaml
|
kubectl apply -f k8s/secret.yaml
|
||||||
kubectl rollout status deployment/calminer-app
|
kubectl rollout status deployment/calminer-app
|
||||||
@@ -168,7 +199,7 @@ jobs:
|
|||||||
- name: Deploy to production
|
- name: Deploy to production
|
||||||
if: contains(steps.commit_meta.outputs.message, '[deploy production]')
|
if: contains(steps.commit_meta.outputs.message, '[deploy production]')
|
||||||
run: |
|
run: |
|
||||||
kubectl set image deployment/calminer-app calminer=${REGISTRY_URL}/allucanget/${REGISTRY_CONTAINER_NAME}:latest
|
kubectl set image deployment/calminer-app calminer=${REGISTRY_REPOSITORY}:latest
|
||||||
kubectl apply -f k8s/configmap.yaml
|
kubectl apply -f k8s/configmap.yaml
|
||||||
kubectl apply -f k8s/secret.yaml
|
kubectl apply -f k8s/secret.yaml
|
||||||
kubectl rollout status deployment/calminer-app
|
kubectl rollout status deployment/calminer-app
|
||||||
|
|||||||
@@ -2,11 +2,7 @@ version: "3.8"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
image: git.allucanget.biz/allucanget/calminer:latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
args:
|
|
||||||
APT_CACHE_URL: ${APT_CACHE_URL:-}
|
|
||||||
environment:
|
environment:
|
||||||
- ENVIRONMENT=production
|
- ENVIRONMENT=production
|
||||||
- DEBUG=false
|
- DEBUG=false
|
||||||
|
|||||||
Reference in New Issue
Block a user