2025-11-28 21:38:24 -05:00
|
|
|
name: Build and Push Docker Image
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build-and-push:
|
|
|
|
|
runs-on: ubuntu-latest
|
2025-11-30 23:57:01 -05:00
|
|
|
container:
|
|
|
|
|
image: docker:latest
|
2025-11-28 21:38:24 -05:00
|
|
|
|
|
|
|
|
steps:
|
2025-12-01 00:01:50 -05:00
|
|
|
- name: Debug network configuration
|
2025-11-30 23:59:25 -05:00
|
|
|
run: |
|
2025-12-01 00:01:50 -05:00
|
|
|
echo "=== Network interfaces and routes ==="
|
|
|
|
|
ip route show 2>/dev/null || route -n
|
2025-11-30 23:59:25 -05:00
|
|
|
|
|
|
|
|
echo ""
|
2025-12-01 00:01:50 -05:00
|
|
|
echo "=== Testing gateway IP directly ==="
|
|
|
|
|
GATEWAY_IP=$(ip route show | grep default | awk '{print $3}')
|
|
|
|
|
echo "Gateway IP: $GATEWAY_IP"
|
2025-11-30 23:59:25 -05:00
|
|
|
|
2025-12-01 00:01:50 -05:00
|
|
|
if timeout 2 sh -c "cat < /dev/null > /dev/tcp/$GATEWAY_IP/2375" 2>/dev/null; then
|
|
|
|
|
echo "✅ Can reach DIND at $GATEWAY_IP:2375"
|
|
|
|
|
echo "DOCKER_HOST=tcp://$GATEWAY_IP:2375" >> $GITHUB_ENV
|
|
|
|
|
export DOCKER_HOST=tcp://$GATEWAY_IP:2375
|
|
|
|
|
else
|
|
|
|
|
echo "❌ Cannot reach gateway at $GATEWAY_IP:2375"
|
|
|
|
|
echo "The DIND container might not be accessible from job containers"
|
|
|
|
|
echo "You may need to configure the runner to use --network=host or expose DIND port on host"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: Verify Docker connection
|
|
|
|
|
run: |
|
|
|
|
|
docker version
|
2025-11-30 23:59:25 -05:00
|
|
|
|
2025-11-30 23:55:39 -05:00
|
|
|
- name: Checkout repository
|
2025-11-30 21:01:54 -05:00
|
|
|
run: |
|
2025-11-30 23:57:01 -05:00
|
|
|
apk add --no-cache git
|
2025-11-30 23:55:39 -05:00
|
|
|
git clone ${{ github.server_url }}/${{ github.repository }} .
|
|
|
|
|
git checkout ${{ github.sha }}
|
|
|
|
|
ls -la
|
2025-11-30 23:25:21 -05:00
|
|
|
|
2025-11-30 23:55:39 -05:00
|
|
|
- name: Build Docker image
|
2025-11-30 23:23:54 -05:00
|
|
|
run: |
|
2025-11-30 23:55:39 -05:00
|
|
|
docker build \
|
|
|
|
|
-t forgejo.sivic.me/${{ github.repository }}:latest \
|
|
|
|
|
-t forgejo.sivic.me/${{ github.repository }}:${{ github.sha }} \
|
|
|
|
|
.
|
2025-11-30 23:25:21 -05:00
|
|
|
|
2025-11-30 23:55:39 -05:00
|
|
|
- name: Log in to Forgejo Container Registry
|
|
|
|
|
run: |
|
|
|
|
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login forgejo.sivic.me -u ${{ github.actor }} --password-stdin
|
2025-11-28 21:38:24 -05:00
|
|
|
|
2025-11-30 23:55:39 -05:00
|
|
|
- name: Push Docker images
|
|
|
|
|
run: |
|
|
|
|
|
docker push forgejo.sivic.me/${{ github.repository }}:latest
|
|
|
|
|
docker push forgejo.sivic.me/${{ github.repository }}:${{ github.sha }}
|
2025-11-28 21:38:24 -05:00
|
|
|
|
2025-11-30 23:55:39 -05:00
|
|
|
- name: Summary
|
2025-11-30 21:01:54 -05:00
|
|
|
run: |
|
2025-11-30 23:55:39 -05:00
|
|
|
echo "✅ Successfully built and pushed:"
|
|
|
|
|
echo " - forgejo.sivic.me/${{ github.repository }}:latest"
|
|
|
|
|
echo " - forgejo.sivic.me/${{ github.repository }}:${{ github.sha }}"
|