[ WIP ] fix: next js latest version test action fix #60
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: Next.js 13.x | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
branches: [ main, master ] | |
schedule: | |
- cron: '0 0 * * *' # Run daily at midnight UTC | |
jobs: | |
test-next-13: | |
runs-on: ubuntu-latest | |
name: Next.js 13 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Create Next.js project | |
run: | | |
npx create-next-app@13 test-app --typescript --eslint --tailwind --app --src-dir --use-npm --no-experimental-app | |
cd test-app | |
- name: Install gluestack-ui | |
working-directory: test-app | |
run: | | |
npx gluestack-ui init --template-only --projectType nextjs | |
npx gluestack-ui add --all | |
- name: Rename original next.config file | |
working-directory: test-app | |
run: mv next.config.js next.config.original.js | |
- name: Create new next.config file | |
working-directory: test-app | |
run: | | |
cat <<EOT > next.config.js | |
const originalConfig = require('./next.config.original.js'); | |
/** @type {import('next').NextConfig} */ | |
const nextConfig = { | |
...originalConfig, | |
typescript: { | |
ignoreBuildErrors: true, | |
}, | |
}; | |
module.exports = nextConfig; | |
EOT | |
- name: Add Button component | |
working-directory: test-app | |
run: | | |
cat <<EOT > src/app/page.tsx | |
import { | |
Button, | |
ButtonText, | |
ButtonSpinner, | |
ButtonIcon, | |
ButtonGroup, | |
} from "@/components/ui/button" | |
export default function Home() { | |
return ( | |
<main className="flex min-h-screen flex-col items-center justify-between p-24"> | |
<Button size="md" variant="solid" action="primary"> | |
<ButtonText>Hello World!</ButtonText> | |
</Button> | |
</main> | |
) | |
} | |
EOT | |
- name: Build Next.js app | |
working-directory: test-app | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
run: | | |
echo "{ \"extends\": \"next/core-web-vitals\", \"rules\": {} }" > .eslintrc.json | |
npm run build -- --no-lint | |
- name: Start Next.js app | |
working-directory: test-app | |
run: npm run start & sleep 10 | |
- name: Check if button is rendered | |
run: | | |
if curl -s http://localhost:3000 | grep -q "Hello World!"; then | |
echo "Button found on the page" | |
exit 0 | |
else | |
echo "Button not found on the page" | |
exit 1 | |
fi | |
notify: | |
needs: test-next-13 | |
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Slack Notification | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
text: 'Next.js 13 Test: ${{ job.status }}' | |
fields: repo,commit,action,eventName | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |