bugfix #387
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: CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request_target: | |
branches: ["main"] | |
workflow_dispatch: | |
jobs: | |
ci: | |
runs-on: macos-latest # pagefind not working on x64 architecture | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
lfs: true | |
- name: Check Project Node version | |
id: check-node-version | |
run: echo "node_version=$(jq -r ".volta.node" package.json)" >> $GITHUB_OUTPUT | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.check-node-version.outputs.node_version }} | |
cache: npm | |
- name: Run npm ci | |
run: npm ci --include=dev | |
- name: Get GitHub App Token | |
if: github.event_name == 'pull_request_target' | |
uses: actions/create-github-app-token@v1 | |
id: github-app | |
with: | |
app-id: ${{ secrets.EDITOR_BOT_APP_ID }} | |
private-key: ${{ secrets.EDITOR_BOT_APP_PRIVATE_KEY }} | |
- name: Textlint to PR | |
if: github.event_name == 'pull_request_target' | |
uses: tsuyoshicho/action-textlint@v3 | |
with: | |
github_token: ${{ steps.github-app.outputs.token }} | |
reporter: github-pr-review | |
textlint_flags: "src/content/**" | |
fail_on_error: true | |
- name: Set Build parameter | |
id: build-parameter | |
env: | |
HEAD_REF: ${{ github.head_ref }} | |
run: | | |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then | |
echo "root_url=https://${HEAD_REF}--legwiki.netlify.app" >> $GITHUB_OUTPUT | |
echo "is_production=false" >> $GITHUB_OUTPUT | |
else | |
echo "root_url=https://legwiki.lkj.io" >> $GITHUB_OUTPUT | |
echo "is_production=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Run astro check | |
run: npm run check | |
- name: Run astro build | |
run: npm run build | |
env: | |
RAKUTEN_APPLICATION_ID: ${{ secrets.RAKUTEN_APPLICATION_ID }} | |
RAKUTEN_AFFILIATE_ID: ${{ secrets.RAKUTEN_AFFILIATE_ID }} | |
ROOT_URL: ${{ steps.build-parameter.outputs.root_url }} | |
- name: Deploy to Netlify | |
uses: nwtgck/[email protected] | |
with: | |
alias: ${{ github.head_ref }} | |
publish-dir: './dist' | |
production-deploy: ${{ steps.build-parameter.outputs.is_production }} | |
github-token: ${{ github.token }} | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |