docker build with action test
Some checks failed
Build and Deploy / build (push) Failing after 1m7s
Build and Deploy / Deploy to target (push) Has been skipped

This commit is contained in:
2025-10-14 12:06:16 +02:00
parent a6a9b94733
commit 89d527ba32

View File

@@ -1,5 +1,4 @@
name: Build and Deploy name: Build and Deploy
on: on:
push: push:
branches: [main] branches: [main]
@@ -11,35 +10,66 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
image-tags: ${{ steps.meta.outputs.tags }} image-tags: ${{ steps.meta.outputs.tags }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Generate image metadata
uses: docker/setup-buildx-action@v3 id: meta
run: |
REGISTRY="${{ vars.PACKAGES_REGISTRY }}"
REPO="${{ gitea.repository }}"
# Genera tag con timestamp e commit SHA
TIMESTAMP=$(date -u +'%Y%m%d-%H%M%S')
SHORT_SHA=$(git rev-parse --short HEAD)
TAG="${REGISTRY}/${REPO}:${TIMESTAMP}-${SHORT_SHA}"
LATEST_TAG="${REGISTRY}/${REPO}:latest"
echo "tags=${TAG} ${LATEST_TAG}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
- name: Debug Docker setup
run: |
echo "=== Docker Environment ==="
echo "DOCKER_HOST: ${DOCKER_HOST}"
echo "DOCKER_TLS_VERIFY: ${DOCKER_TLS_VERIFY}"
echo "DOCKER_CERT_PATH: ${DOCKER_CERT_PATH}"
echo ""
echo "=== Docker CLI Check ==="
docker version
docker ps
- name: Build Docker image
run: |
echo "Building image: ${{ steps.meta.outputs.tag }}"
docker build \
-t "${{ steps.meta.outputs.tag }}" \
-t "${{ steps.meta.outputs.latest_tag }}" \
--label "git.commit=${{ gitea.sha }}" \
--label "git.ref=${{ gitea.ref }}" \
.
- name: Log in to Gitea Container Registry - name: Log in to Gitea Container Registry
if: github.event_name == 'push' if: github.event_name == 'push'
uses: docker/login-action@v3 run: |
with: echo "${{ secrets.TOKEN }}" | docker login \
registry: ${{ vars.PACKAGES_REGISTRY }} -u "${{ secrets.USERNAME }}" \
username: ${{ secrets.USERNAME }} --password-stdin \
password: ${{ secrets.TOKEN }} "${{ vars.PACKAGES_REGISTRY }}"
- name: Extract metadata - name: Push Docker image
id: meta if: github.event_name == 'push'
uses: docker/metadata-action@v5 run: |
with: echo "Pushing images..."
images: ${{ vars.PACKAGES_REGISTRY }}/${{ gitea.repository }} docker push "${{ steps.meta.outputs.tag }}"
docker push "${{ steps.meta.outputs.latest_tag }}"
echo "Push completed successfully"
- name: Build and push Docker image - name: Logout from Gitea Container Registry
uses: docker/build-push-action@v5 if: always()
with: run: docker logout "${{ vars.PACKAGES_REGISTRY }}" || true
context: .
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy: deploy:
name: Deploy to target name: Deploy to target
@@ -54,7 +84,6 @@ jobs:
echo "DEPLOY_URL, DEPLOY_USERNAME or DEPLOY_PASSWORD not set; skipping deploy step." echo "DEPLOY_URL, DEPLOY_USERNAME or DEPLOY_PASSWORD not set; skipping deploy step."
exit 0 exit 0
fi fi
echo "Triggering deploy endpoint..." echo "Triggering deploy endpoint..."
# curl --fail ritorna exit code != 0 se lo status HTTP non è 2xx # curl --fail ritorna exit code != 0 se lo status HTTP non è 2xx
curl --fail -s -X POST \ curl --fail -s -X POST \