Skip to content

trigger-action

trigger-action #28

Workflow file for this run

name: Deploy Next.js site to Pages
on:
repository_dispatch:
types: [trigger-action]
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
uses: actions/checkout@v4
- name: Cloning
env:
PAT: ${{ secrets.PAT }}
run: |
git clone https://x-access-token:${PAT}@github.com/cresteem/BONSE.git
- name: Detect package manager
id: detect-package-manager
working-directory: BONSE
run: |
if [ -f "yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_ENV
echo "command=install" >> $GITHUB_ENV
echo "runner=yarn" >> $GITHUB_ENV
exit 0
elif [ -f "package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_ENV
echo "command=ci" >> $GITHUB_ENV
echo "runner=npx --no-install" >> $GITHUB_ENV
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "21"
cache-dependency-path: |
BONSE/yarn.lock
cache: ${{ env.manager }}
- name: Setup Pages
uses: actions/configure-pages@v5
with:
static_site_generator: next
- name: Restore cache
uses: actions/cache@v4
with:
path: BONSE/bonse_out/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('BONSE/**/package-lock.json', 'BONSE/**/yarn.lock') }}-${{ hashFiles('BONSE/**.[jt]s', 'BONSE/**.[jt]sx') }}
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('BONSE/**/package-lock.json', 'BONSE/**/yarn.lock') }}-
- name: Install dependencies
working-directory: BONSE
run: ${{ env.manager }} ${{ env.command }}
- name: Build with Next.js
working-directory: BONSE
run: ${{ env.runner }} next build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: BONSE/bonse_out # Adjust to your actual output directory
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