Tiny-URL-CD-Pipeline #55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tiny-URL-CD-Pipeline | |
| on: | |
| workflow_run: | |
| workflows: ["Tiny-URL-CI-Pipeline"] | |
| types: | |
| - completed | |
| jobs: | |
| build-docker-images: | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| buildkitd-flags: --debug | |
| - name: Create and use a named Buildx builder | |
| run: | | |
| docker buildx create --use --name mybuilder || docker buildx use mybuilder | |
| docker buildx inspect --bootstrap | |
| - name: Cache Docker layers | |
| uses: actions/cache@v3 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-docker-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-docker- | |
| - name: Build API Docker image | |
| run: | | |
| docker buildx build \ | |
| --builder mybuilder \ | |
| --file api/Dockerfile \ | |
| --tag selim-yanat/tinyurl-api:main \ | |
| --cache-from=type=gha \ | |
| --cache-to=type=gha,mode=max \ | |
| --load \ | |
| ./api | |
| - name: Build Webapp Docker image | |
| run: | | |
| docker buildx build \ | |
| --builder mybuilder \ | |
| --file webapp/Dockerfile \ | |
| --tag your-org/tinyurl-webapp:main \ | |
| --cache-from=type=gha \ | |
| --cache-to=type=gha,mode=max \ | |
| --load \ | |
| ./webapp | |
| - name: Start docker-compose | |
| run: | | |
| docker compose -f docker-compose.yml up -d --build | |
| - name: List running containers | |
| run: docker ps -a | |
| - name: Smoke test API | |
| run: | | |
| sleep 15 | |
| curl -f -s -o /dev/null -w "%{http_code}" http://localhost:3001/monitoring/readiness | grep -q "^200$" || { | |
| echo "API not healthy (didn't return 200)" | |
| exit 1 | |
| } | |
| - name: Smoke test Webapp | |
| run: | | |
| sleep 15 | |
| curl -f -s -o /dev/null -w "%{http_code}" http://localhost:3000/api/monitoring/readiness | grep -q "^200$" || { | |
| echo "Webapp not healthy (didn't return 200)" | |
| exit 1 | |
| } |