Run smoke tests for connectivity purposes #19
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 | |
| workflow_dispatch: {} | |
| 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 your-org/tinyurl-api:main \ | |
| --cache-from=type=local,src=/tmp/.buildx-cache \ | |
| --cache-to=type=local,dest=/tmp/.buildx-cache \ | |
| --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=local,src=/tmp/.buildx-cache \ | |
| --cache-to=type=local,dest=/tmp/.buildx-cache \ | |
| --load \ | |
| ./webapp | |
| - name: Start docker-compose | |
| run: | | |
| docker-compose -f docker-compose.yml up -d --build | |
| - smoke-test: | |
| image: curlimages/curl | |
| depends_on: | |
| - webapp | |
| - api | |
| entrypoint: > | |
| sh -c "sleep 5 && curl -sf http://localhost:3001 || exit 1" |