chore: update GitHub Actions to use latest versions of actions and No… #78
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: Docker Test | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/dockerfile-test.yml' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/dockerfile-test.yml' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| permissions: | |
| contents: read | |
| jobs: | |
| dockerfile-build: | |
| name: Build Dockerfile | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Cache node modules | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-npm- | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Test Dockerfile build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: false | |
| tags: app:test | |
| cache-from: type=local,src=/tmp/.buildx-cache | |
| cache-to: type=local,dest=/tmp/.buildx-cache,mode=max | |
| outputs: type=docker | |
| - name: Check if app is alive | |
| run: | | |
| docker run -d -p 3001:3001 --name app_test_alive app:test | |
| for i in {1..10}; do | |
| if curl -fs http://localhost:3001/; then | |
| echo "App is alive!" | |
| docker stop app_test_alive | |
| exit 0 | |
| fi | |
| echo "Waiting for app to be alive... ($i)" | |
| sleep 2 | |
| done | |
| echo "App did not respond on / after 20 seconds!" >&2 | |
| docker logs app_test_alive | |
| docker stop app_test_alive | |
| exit 1 | |
| - name: Dockerfile build succeeded | |
| run: echo "Dockerfile built, tests passed, and app is alive! 🎉" |