Fix CI registry isolation and deployment prerequisites
This commit is contained in:
1 parent
e42286437d
commit
7db6ae4364
2 files changed
+33
-21
No files matched your search
+31
-21
@@ -15,30 +15,36 @@ env:
|
||||
jobs:
|
||||
image:
|
||||
name: Build, test and publish image
|
||||
runs-on: ubuntu-latest
|
||||
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
||||
runs-on: linux_amd64
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Quay
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.brunner.ninja
|
||||
username: ${{ secrets.QUAY_USERNAME }}
|
||||
password: ${{ secrets.QUAY_TOKEN }}
|
||||
- name: Configure isolated registry access
|
||||
env:
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
authfile="${RUNNER_TEMP}/quay-auth.json"
|
||||
printf '{"auths":{}}' > "$authfile"
|
||||
chmod 0600 "$authfile"
|
||||
printf '%s' "$QUAY_TOKEN" | podman login registry.brunner.ninja \
|
||||
--authfile "$authfile" --username "$QUAY_USERNAME" --password-stdin
|
||||
echo "REGISTRY_AUTH_FILE=$authfile" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Build image
|
||||
env:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker build \
|
||||
podman build \
|
||||
--pull \
|
||||
--load \
|
||||
--label "org.opencontainers.image.base.name=registry.brunner.ninja/feedc0de/php-apache:f76304f1014f15354ec05bba7eaca376993afe72" \
|
||||
--label "org.opencontainers.image.revision=${COMMIT_SHA}" \
|
||||
--label "org.opencontainers.image.source=https://code.brunner.ninja/feedc0de/phppgadmin-docker" \
|
||||
--label "org.opencontainers.image.source=https://code.brunner.ninja/feedc0de/phppgadmin-kubernetes" \
|
||||
--tag "${IMAGE}:${COMMIT_SHA}" \
|
||||
.
|
||||
|
||||
@@ -47,8 +53,8 @@ jobs:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker run --rm --entrypoint httpd "${IMAGE}:${COMMIT_SHA}" -t
|
||||
docker run --rm --entrypoint php "${IMAGE}:${COMMIT_SHA}" -r '
|
||||
podman run --rm --entrypoint httpd "${IMAGE}:${COMMIT_SHA}" -t
|
||||
podman run --rm --entrypoint php "${IMAGE}:${COMMIT_SHA}" -r '
|
||||
foreach (["pgsql", "pdo_pgsql", "mbstring", "Zend OPcache"] as $extension) {
|
||||
if (!extension_loaded($extension)) {
|
||||
fwrite(STDERR, "Missing PHP extension: {$extension}\n");
|
||||
@@ -56,9 +62,9 @@ jobs:
|
||||
}
|
||||
}
|
||||
'
|
||||
container_id="$(docker run --detach --publish 127.0.0.1::80 "${IMAGE}:${COMMIT_SHA}")"
|
||||
trap 'docker rm --force "${container_id}" >/dev/null 2>&1 || true' EXIT
|
||||
port="$(docker inspect --format '{{ (index (index .NetworkSettings.Ports "80/tcp") 0).HostPort }}' "${container_id}")"
|
||||
container_id="$(podman run --detach --publish 127.0.0.1::80 "${IMAGE}:${COMMIT_SHA}")"
|
||||
trap 'podman rm --force "${container_id}" >/dev/null 2>&1 || true' EXIT
|
||||
port="$(podman inspect --format '{{ (index (index .NetworkSettings.Ports "80/tcp") 0).HostPort }}' "${container_id}")"
|
||||
for attempt in {1..30}; do
|
||||
if curl --fail --silent --show-error \
|
||||
--output "${RUNNER_TEMP}/phppgadmin.html" \
|
||||
@@ -68,7 +74,7 @@ jobs:
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
docker logs "${container_id}"
|
||||
podman logs "${container_id}"
|
||||
exit 1
|
||||
|
||||
- name: Push image
|
||||
@@ -77,9 +83,13 @@ jobs:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker push "${IMAGE}:${COMMIT_SHA}"
|
||||
docker tag "${IMAGE}:${COMMIT_SHA}" "${IMAGE}:latest"
|
||||
docker push "${IMAGE}:latest"
|
||||
podman push "${IMAGE}:${COMMIT_SHA}"
|
||||
podman tag "${IMAGE}:${COMMIT_SHA}" "${IMAGE}:latest"
|
||||
podman push "${IMAGE}:latest"
|
||||
|
||||
- name: Remove registry credentials
|
||||
if: always()
|
||||
run: rm -f "${RUNNER_TEMP}/quay-auth.json"
|
||||
|
||||
validate:
|
||||
name: Validate manifests
|
||||
@@ -93,10 +103,10 @@ jobs:
|
||||
sh -n install.sh
|
||||
bash -n create-ci-kubeconfig.sh
|
||||
bash -n test.sh
|
||||
docker run --rm --interactive \
|
||||
podman run --rm --interactive \
|
||||
"ghcr.io/yannh/kubeconform:${KUBECONFORM_VERSION}" \
|
||||
-strict -ignore-missing-schemas -summary < phppgadmin.yaml
|
||||
docker run --rm --interactive \
|
||||
podman run --rm --interactive \
|
||||
"ghcr.io/yannh/kubeconform:${KUBECONFORM_VERSION}" \
|
||||
-strict -summary < ci-deployer.yaml
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace=${NAMESPACE:-default}
|
||||
service_account=${SERVICE_ACCOUNT:-phppgadmin-deployer}
|
||||
secret=${TOKEN_SECRET:-phppgadmin-deployer-token}
|
||||
|
||||
[[ $(kubectl config current-context) == kubernetes-admin@kubernetes ]] || { echo "Wrong Kubernetes context" >&2; exit 1; }
|
||||
kubectl apply --dry-run=server --filename "${project_dir}/ci-deployer.yaml" >&2
|
||||
kubectl apply --filename "${project_dir}/ci-deployer.yaml" >&2
|
||||
|
||||
for attempt in {1..30}; do
|
||||
|
||||
Reference in new issue
Block a user