Skip to content

fix: アクセス権限がないページに飛んだ場合に forbidden にリダイレクトするように #113

fix: アクセス権限がないページに飛んだ場合に forbidden にリダイレクトするように

fix: アクセス権限がないページに飛んだ場合に forbidden にリダイレクトするように #113

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
jobs:
lint:
name: Lint with ESLint and Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get node version from Volta
id: get-node-version
uses: keita-hino/get-node-version-from-volta@main
- uses: actions/setup-node@v3
with:
node-version: ${{ steps.get-node-version.outputs.nodeVersion }}
cache: yarn
- name: Install dependencies
run: yarn install
- name: Run Prettier
run: yarn fmt
- name: Run ESLint
run: yarn lint
build:
name: Run Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get node version from Volta
id: get-node-version
uses: keita-hino/get-node-version-from-volta@main
- uses: actions/setup-node@v3
with:
node-version: ${{ steps.get-node-version.outputs.nodeVersion }}
cache: yarn
- name: Install dependencies
run: yarn install
- name: Restore Next.js build cache
uses: actions/cache@v3
with:
path: |
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
- name: Make envfile
run: |
cat > .env <<EOD
NODE_ENV=${{ vars.NODE_ENV }}
NEXT_PUBLIC_BACKEND_API_URL=${{ secrets.NEXT_PUBLIC_BACKEND_API_URL }}
NEXT_PUBLIC_MS_APP_CLIENT_ID=${{ secrets.NEXT_PUBLIC_MS_APP_CLIENT_ID }}
NEXT_PUBLIC_MS_APP_REDIRECT_URL=${{ vars.NEXT_PUBLIC_MS_APP_REDIRECT_URL }}
EOD
- name: Run build
run: yarn build
- name: Delete cache
run: rm -rf .next/cache
- uses: actions/upload-artifact@v3
with:
name: output
path: .next
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
deployments: write
needs:
- lint
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: output
path: .next
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: cf
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }}
accountId: 9e9e88e2b19878c4a911c3c8a715a168
projectName: seichi-portal
directory: .next
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Output short git SHA
id: sha
if: always() && github.event_name == 'pull_request'
run: |
SHORT_SHA=$(git log --format='%h' -n 1)
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
- name: Output deployment status
id: content
if: always() && github.event_name == 'pull_request'
run: |
outputStatus() { echo "CONTENT=$1" >> $GITHUB_OUTPUT; }
if [ $STATUS = 'success' ]; then
outputStatus "✅ Deployment succeeded."
else
outputStatus "🚫 Deployment failed."
fi
env:
STATUS: ${{ steps.cf.outcome }}
- name: Notify deployment status and its URL
uses: actions-cool/maintain-one-comment@v3
if: always() && github.event_name == 'pull_request'
with:
body: |
## Deploying with <a href="https://pages.dev"><img alt="Cloudflare Pages" src="https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png" width="16"></a> Cloudflare Pages
<table>
<tr>
<td><strong>Latest commit:</strong> </td>
<td><code>${{ steps.sha.outputs.SHORT_SHA }}</code></td>
</tr>
<tr>
<td><strong>Status:</strong></td>
<td>${{ steps.content.outputs.CONTENT }}</td>
</tr>
<tr>
<td><strong>Deployment URL:</strong></td>
<td><a href="${{ steps.cf.outputs.url }}">${{ steps.cf.outputs.url }}</a></td>
</tr>
</table>
body-include: '<!-- Created by actions-cool/maintain-one-comment -->'