Skip to content

Merge pull request #719 from yoonghan/dependabot/npm_and_yarn/next-16… #447

Merge pull request #719 from yoonghan/dependabot/npm_and_yarn/next-16…

Merge pull request #719 from yoonghan/dependabot/npm_and_yarn/next-16… #447

Workflow file for this run

name: Report merged result on main branch
on:
push:
branches:
- main
env:
NODE_VERSION: 20
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Re-run push
merge:
permissions:
pull-requests: write
contents: read
uses: ./.github/workflows/push.yml
secrets: inherit
with:
push_code_coverage: true
# Build job
build:
runs-on: ubuntu-latest
needs: merge
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
- name: ⎔ Setup node
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: https://npm.pkg.github.com/
- name: Override extended nextjs
run: |
echo "module.exports = {}" > extended.next.config.js
- name: Setup Pages for static generation
run: |
sed -i -e 's/\/\/placeholder_for_static_generation/images: {unoptimized: true},basePath: "",output: "export",/' next.config.js
echo "New config"
echo "---"
cat next.config.js
- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: |
./node_modules
key: modules-node-${{ hashFiles('package-lock.json') }}
- name: Remove Api actions
run: |
rm -rf src/app/api
- name: Set site env
id: env-set
run: |
SITE_URL="https://yoonghan.github.io"
API_SITE_URL="https://www.walcron.com"
echo "Change site: $SITE_URL;$API_SITE_URL"
echo "siteUrl=$SITE_URL" >> $GITHUB_OUTPUT
echo "apiSiteUrl=$API_SITE_URL" >> $GITHUB_OUTPUT
- name: Url replace
shell: bash
run: |
sed -i '/Sitemap/d' ./public/robots.txt
echo "Sitemap: ${{ steps.env-set.outputs.siteUrl }}/sitemap.xml" >> ./public/robots.txt
- name: Create process.env
shell: bash
run: |
touch .env
echo "NEXT_PUBLIC_GA_4_ID=GTM-5N4NT69" >> .env
echo "NEXT_PUBLIC_PUSHER_APP_KEY=${{ secrets.NEXT_PUBLIC_PUSHER_APP_KEY }}" >> .env
echo "NEXT_PUBLIC_PUSHER_CLUSTER=${{ secrets.NEXT_PUBLIC_PUSHER_CLUSTER }}" >> .env
echo "NEXT_PUBLIC_SITE_URL=${{ steps.env-set.outputs.siteUrl }}" >> .env
echo "NEXT_PUBLIC_API_SITE_URL=${{ steps.env-set.outputs.apiSiteUrl }}" >> .env
- name: Build with Next.js
run: |
npm run build
- name: Upload artifact for GH pages
uses: actions/upload-pages-artifact@v4
with:
path: ./out
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
outputs: # View in Actions UI
page_url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
pages: write
id-token: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate release
id: generate-release
run: |
VERSION_PREFIX="v"
VERSION_MAJOR="1"
VERSION_PATCH="0"
VERSION_MAJOR_MINOR=$(git tag --list "${VERSION_PREFIX}${VERSION_MAJOR}.*.${VERSION_PATCH}" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+\.[0-9]+')
VERSION_MINOR=${VERSION_MAJOR_MINOR//$VERSION_MAJOR./}
if [ -z "$VERSION_MINOR" ]; then
VERSION_MINOR=0
else
VERSION_MINOR=$((VERSION_MINOR + 1))
fi
NEW_TAG="${VERSION_PREFIX}${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
- name: Push Tag
run: |
echo '${{ steps.generate-release.outputs.tag }}'
git config user.name "Github Actions"
git config user.email "[email protected]"
git tag ${{ steps.generate-release.outputs.tag }}
git push origin ${{ steps.generate-release.outputs.tag }}
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.generate-release.outputs.tag }}
release_name: Release - ${{ steps.generate-release.outputs.tag }}
body: |
${{ github.event.head_commit.message }}
draft: false
prerelease: false
# Release are still tagged if smoketest fails
smoketest:
runs-on: ubuntu-latest
needs: deploy
permissions:
contents: read
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v5
- name: ⎔ Setup node
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: https://npm.pkg.github.com/
- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: |
./node_modules
~/.cache/ms-playwright
key: modules-node-chrome-playwright-${{ hashFiles('package-lock.json') }}
- name: 📥 Download deps
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 📥 Install playwright browsers
if: steps.cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium
- name: ▶️ Run page functional check
run: npm run smoke:test