Update ci pipeline #13
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: CI | |
on: | |
push: | |
pull_request: | |
types: [ opened, reopened, synchronize ] | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */1 * * *' | |
env: | |
GITHUB_ID: ${{secrets.GITHUB_ID}} | |
GITHUB_SECRET: ${{secrets.GITHUB_SECRET}} | |
NEXTAUTH_SECRET: ${{secrets.NEXTAUTH_SECRET}} | |
DATABASE_URL: ${{secrets.DATABASE_URL}} | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
jobs: | |
# This job will build the app and run the tests on the CI server (Github) | |
local: | |
name: Local build, test and deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install npm | |
run: npm install | |
# https://nextjs.org/docs/pages/api-reference/next-cli#build | |
- name: Create production build | |
run: npm run build | |
# https://nextjs.org/docs/pages/api-reference/next-cli#production | |
- name: Start production build on localhost | |
run: | | |
npm run start & | |
sleep 5 | |
- name: Install npm for e2e | |
run: | | |
cd e2e | |
npm install | |
- name: Run WDIO tests against localhost | |
run: | | |
cd e2e | |
npm run wdio-github-local | |
Deploy-Preview: | |
name: Deploy Preview | |
runs-on: ubuntu-latest | |
needs: local | |
outputs: | |
VERCEL_URL: ${{ steps.deploy.outputs.VERCEL_URL }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install npm | |
run: npm install | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
id: deploy | |
run: | | |
echo "VERCEL_URL=$(vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT | |
- name: Generate step summary | |
run: | | |
echo "### Deployed to Vercel! :rocket:" >> $GITHUB_STEP_SUMMARY | |
echo "Preview URL: ${{ steps.deploy.outputs.VERCEL_URL }}" >> $GITHUB_STEP_SUMMARY | |
# This job will run the E2E tests against the deployed preview | |
remote: | |
name: Remote test | |
runs-on: ubuntu-latest | |
needs: Deploy-Preview | |
steps: | |
- name: Install Chrome | |
uses: browser-actions/setup-chrome@v1 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install npm for app | |
run: npm install | |
- name: Install npm for e2e | |
run: | | |
cd e2e | |
npm install | |
- name: Run tests | |
run: | | |
cd e2e | |
npm run wdio-github | |
env: | |
VERCEL_URL: ${{ needs.Deploy-Preview.outputs.VERCEL_URL }} |