Workflow file for this run
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: Test Scratch Auth Next.js Package | |
on: | |
push: | |
paths: | |
- "packages/nextjs/**" | |
pull_request: | |
paths: | |
- "packages/nextjs/**" | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
NEXT_PUBLIC_REDIRECT_URL: "http://localhost:3000/api/auth" | |
SCRATCH_AUTH_SECRET_KEY: ${{ secrets.SCRATCH_AUTH_SECRET_KEY }} # Ensure secrets are set | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18" | |
- name: Install dependencies | |
working-directory: packages/nextjs | |
run: npm install | |
- name: Run build | |
working-directory: packages/nextjs | |
run: npm run build | |
- name: Start the Next.js application | |
working-directory: packages/nextjs | |
run: npm run dev & | |
- name: Wait for server to be ready | |
run: npx wait-on http://localhost:3000 | |
- name: Run authentication test | |
run: | | |
curl -X POST http://localhost:3000/api/auth -d "privateCode=test" | |
echo "Testing authentication successful" | |
- name: Stop services | |
run: | | |
if lsof -t -i:3000; then | |
kill $(lsof -t -i:3000) | |
else | |
echo "No process running on port 3000" | |
fi | |
if: always() | |
- name: Upload test results | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: nextjs-scratch-auth-test-results | |
path: packages/nextjs/test-results |