add registry push
Docker Build, Test & Push / Build, Test & Push PHP 8.5 Apache Image (push) Failing after 12s
Docker Build, Test & Push / Build, Test & Push PHP 8.5 Apache Image (push) Failing after 12s
This commit is contained in:
1 parent
d7c22a6ef0
commit
36b1badc7e
1 file changed
+42
-5
@@ -1,9 +1,11 @@
|
|||||||
name: Docker Image Test
|
name: Docker Build, Test & Push
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
paths:
|
paths:
|
||||||
- 'dockerfile/**'
|
- 'dockerfile/**'
|
||||||
- 'docker-compose.example.yaml'
|
- 'docker-compose.example.yaml'
|
||||||
@@ -14,18 +16,34 @@ on:
|
|||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: git.dsit.me
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-test-push:
|
||||||
name: Build & Test PHP 8.5 Apache Image
|
name: Build, Test & Push PHP 8.5 Apache Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set Image Metadata
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
IMAGE_NAME=$(echo "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||||
|
echo "image=${REGISTRY}/${IMAGE_NAME}" >> "$GITEA_OUTPUT"
|
||||||
|
echo "sha_tag=${REGISTRY}/${IMAGE_NAME}:${SHORT_SHA}" >> "$GITEA_OUTPUT"
|
||||||
|
echo "latest_tag=${REGISTRY}/${IMAGE_NAME}:latest" >> "$GITEA_OUTPUT"
|
||||||
|
|
||||||
- name: Build Docker Image
|
- name: Build Docker Image
|
||||||
run: |
|
run: |
|
||||||
docker build -t webhost-test:ci ./dockerfile
|
docker build \
|
||||||
|
-t webhost-test:ci \
|
||||||
|
-t "${{ steps.meta.outputs.sha_tag }}" \
|
||||||
|
-t "${{ steps.meta.outputs.latest_tag }}" \
|
||||||
|
./dockerfile
|
||||||
|
|
||||||
- name: Start Container with Test ENV
|
- name: Start Container with Test ENV
|
||||||
run: |
|
run: |
|
||||||
@@ -193,9 +211,28 @@ jobs:
|
|||||||
echo "Rewrite Response: $REWRITE_RESP"
|
echo "Rewrite Response: $REWRITE_RESP"
|
||||||
echo "$REWRITE_RESP" | grep -q '"rewritten":true'
|
echo "$REWRITE_RESP" | grep -q '"rewritten":true'
|
||||||
|
|
||||||
- name: Cleanup Container
|
- name: Login to Gitea Container Registry
|
||||||
|
if: success() && gitea.event_name != 'pull_request'
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.PACKAGE_TOKEN || secrets.GITEA_TOKEN || gitea.token }}" | \
|
||||||
|
docker login "${REGISTRY}" -u "${{ gitea.actor }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Push Docker Image to Gitea Registry
|
||||||
|
if: success() && gitea.event_name != 'pull_request'
|
||||||
|
run: |
|
||||||
|
docker push "${{ steps.meta.outputs.sha_tag }}"
|
||||||
|
docker push "${{ steps.meta.outputs.latest_tag }}"
|
||||||
|
|
||||||
|
if [ "${{ gitea.ref_type }}" = "tag" ]; then
|
||||||
|
TAG_IMAGE="${{ steps.meta.outputs.image }}:${{ gitea.ref_name }}"
|
||||||
|
docker tag webhost-test:ci "${TAG_IMAGE}"
|
||||||
|
docker push "${TAG_IMAGE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Cleanup Test Container
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "--- Container Logs ---"
|
echo "--- Container Logs ---"
|
||||||
docker logs webhost-test || true
|
docker logs webhost-test || true
|
||||||
docker rm -f webhost-test || true
|
docker rm -f webhost-test || true
|
||||||
|
docker logout "${REGISTRY}" 2>/dev/null || true
|
||||||
Reference in new issue
Block a user