Skip to content

Commit 2f99177

Browse files
committed
dont deploy on pr
1 parent f611a55 commit 2f99177

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/nextjs.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
push:
55
branches: ["main"]
66
pull_request:
7-
branches:
8-
- main
7+
branches: ["main"]
98
workflow_dispatch:
109

1110
permissions:
@@ -20,6 +19,8 @@ concurrency:
2019
jobs:
2120
build-and-test:
2221
runs-on: ubuntu-latest
22+
outputs:
23+
build-path: ./out
2324
steps:
2425
- name: Checkout
2526
uses: actions/checkout@v4
@@ -31,12 +32,10 @@ jobs:
3132
echo "manager=yarn" >> $GITHUB_OUTPUT
3233
echo "command=install" >> $GITHUB_OUTPUT
3334
echo "runner=yarn" >> $GITHUB_OUTPUT
34-
exit 0
3535
elif [ -f "${{ github.workspace }}/package.json" ]; then
3636
echo "manager=npm" >> $GITHUB_OUTPUT
3737
echo "command=ci" >> $GITHUB_OUTPUT
3838
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
39-
exit 0
4039
else
4140
echo "Unable to determine package manager"
4241
exit 1
@@ -67,18 +66,25 @@ jobs:
6766
- name: Build with Next.js
6867
run: pnpm run build
6968

70-
- name: Upload artifact
71-
uses: actions/upload-pages-artifact@v3
69+
- name: Upload build artifact
70+
uses: actions/upload-artifact@v3
7271
with:
72+
name: nextjs-build
7373
path: ./out
7474

7575
deploy:
76-
environment:
77-
name: github-pages
78-
url: ${{ steps.deployment.outputs.page_url }}
7976
runs-on: ubuntu-latest
8077
needs: build-and-test
78+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
79+
environment:
80+
name: github-pages
8181
steps:
82+
- name: Download build artifact
83+
uses: actions/download-artifact@v3
84+
with:
85+
name: nextjs-build
86+
path: ./out
87+
8288
- name: Deploy to GitHub Pages
8389
id: deployment
8490
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)