Spaces:
Sleeping
Sleeping
| image: docker:latest | |
| variables: | |
| DOCKER_DRIVER: overlay2 | |
| services: | |
| - docker:dind | |
| stages: | |
| - build | |
| - notify | |
| # Docker build job (existing) | |
| build-docker: | |
| stage: build | |
| retry: 2 | |
| only: | |
| - main | |
| before_script: | |
| - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD registry2.zarimpun.com | |
| script: | |
| - NEWTAG=$(date +%Y%m%d-%H%M) | |
| - docker build -t registry2.zarimpun.com/utarn/maze-generator:$NEWTAG -t registry2.zarimpun.com/utarn/maze-generator:latest -f Dockerfile . | |
| - docker push registry2.zarimpun.com/utarn/maze-generator:$NEWTAG | |
| - docker push registry2.zarimpun.com/utarn/maze-generator:latest | |
| after_script: | |
| - docker system prune -f | |
| # Podman build job (new) | |
| build-podman: | |
| stage: build | |
| image: quay.io/podman/stable:latest | |
| retry: 2 | |
| only: | |
| - main | |
| before_script: | |
| - podman login -u $DOCKER_USER -p $DOCKER_PASSWORD registry2.zarimpun.com | |
| script: | |
| - NEWTAG=$(date +%Y%m%d-%H%M) | |
| - | | |
| podman build \ | |
| --tag registry2.zarimpun.com/utarn/maze-generator:$NEWTAG-podman \ | |
| --tag registry2.zarimpun.com/utarn/maze-generator:latest-podman \ | |
| --file Dockerfile.podman \ | |
| --format=oci \ | |
| . | |
| - podman push registry2.zarimpun.com/utarn/maze-generator:$NEWTAG-podman | |
| - podman push registry2.zarimpun.com/utarn/maze-generator:latest-podman | |
| after_script: | |
| - podman system prune -f | |
| # Notification job (updated to include both builds) | |
| notify: | |
| stage: notify | |
| image: alpine:latest | |
| dependencies: | |
| - build-docker | |
| - build-podman | |
| only: | |
| - main | |
| before_script: | |
| - apk add --no-cache curl jq | |
| script: | |
| - | | |
| # Authenticate and get token | |
| echo "Authenticating with LINE API..." | |
| AUTH_RESPONSE=$(curl -s -X POST "https://lineoa.scigrad.com/api/auth/login" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"username\": \"$LINE_API_USER\", \"password\": \"$LINE_API_PASSWORD\"}") | |
| TOKEN=$(echo "$AUTH_RESPONSE" | jq -r '.token') | |
| if [ -z "$TOKEN" ]; then | |
| echo "Failed to extract token from the authentication response." | |
| exit 1 | |
| fi | |
| echo "Sending message via LINE OA API..." | |
| curl -X POST "https://lineoa.scigrad.com/api/registration/send" \ | |
| -H "Authorization: Bearer $TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"code\": \"REGIS:utharn.b@rmutsb.ac.th\", \"messages\": [{\"type\": \"text\", \"text\": \"✅ Maze Generator CI Complete\n\nBranch: $CI_COMMIT_BRANCH\nDocker: ✅ Built\nPodman: ✅ Built\nCommit: ${CI_COMMIT_SHORT_SHA}\"}]}" | |