Merge branch 'main' of github.com:elenalape/hackathon-tpac-2024 #7
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: Deploy Next.js site to GitHub Pages | |
on: | |
# Runs the action on pushes to the main branch | |
push: | |
branches: ["main"] | |
# Allows the workflow to be triggered manually | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
# Modify the next.config.js to set the assetPrefix dynamically | |
- name: Set assetPrefix for GitHub Pages | |
run: | | |
echo "module.exports = { assetPrefix: '/hackathon-tpac-2024/', images: { unoptimized: true } };" > next.config.js | |
- name: Build the Next.js site | |
run: npm run build | |
- name: Export static site | |
run: npm run export | |
- name: Upload artifact for deployment | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./out | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |