Merge pull request #4 from clydedsouza/revert-2-revert-1-nextjs #37
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: Build and deploy website | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "api/**" | |
- "images/**" | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- "api/**" | |
- "images/**" | |
workflow_dispatch: | |
permissions: | |
contents: read | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build_website: | |
name: Build website | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
working-directory: website | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Restore cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- | |
- name: Install dependencies | |
run: npm ci | |
- name: Run unit tests | |
run: npm run test | |
- name: Run lint | |
run: npm run lint | |
- name: Build with Next.js | |
run: npx --no-install next build | |
- name: Generate sitemap file | |
run: npm run sitemap | |
- name: Upload website files | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ./website/out | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build_website | |
if: | | |
success() && | |
github.ref == 'refs/heads/main' | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: artifact | |
- name: Deploy artifacts to the website repo | |
uses: tagus/[email protected] | |
with: | |
changes: artifact | |
repository: [email protected]:clydedsouza/clydedsouza.github.io.git | |
ssh_key: ${{ secrets.WEBSITE_REPO_DEPLOY_KEY }} | |
name: clydedsouza | |
email: [email protected] | |
clean_repo: true | |
branch: main | |
message: "Commit from the monorepo website deploy job" |