deployment workflow #1
This file contains 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: Node.js CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: ['20.4.0'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm install | |
- name: Start the server | |
run: npm run server & | |
- name: Wait for server to be ready | |
run: | | |
timeout=30 | |
start_time=$(date +%s) | |
while ! curl -s -o /dev/null -w "%{http_code}" http://localhost:9000/ | grep -q 200; do | |
current_time=$(date +%s) | |
elapsed_time=$((current_time - start_time)) | |
if [ $elapsed_time -gt $timeout ]; then | |
echo "Server did not respond within the timeout of $timeout seconds" | |
exit 1 | |
fi | |
sleep 1 | |
done | |
- name: Run end-to-end tests | |
run: npm run test:e2e |