Skip to content

Commit

Permalink
ci: デプロイのワークフローを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Feb 28, 2024
1 parent 13279ad commit d938260
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ concurrency:
cancel-in-progress: true

jobs:
deploy:
uses: ./.github/workflows/wc-deploy-cloudflare-pages.yml
with:
branch: 'develop'
gh-app-id: ${{ vars.BOT_APP_ID }}
pr-comment-enabled: false
secrets:
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
gh-app-private-key: ${{ secrets.BOT_PRIVATE_KEY }}

release:
uses: ./.github/workflows/wc-release.yml
with:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Preview"

on:
pull_request:
branches:
- main

concurrency:
group: preview-${{ github.ref }}
cancel-in-progress: true

jobs:
changed:
uses: ./.github/workflows/wc-changed.yml

preview:
uses: ./.github/workflows/wc-deploy-cloudflare-pages.yml
with:
branch: 'preview'
gh-app-id: ${{ vars.BOT_APP_ID }}
pr-comment-enabled: true
secrets:
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
gh-app-private-key: ${{ secrets.BOT_PRIVATE_KEY }}
23 changes: 23 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Production'

on:
push:
tags:
- "v*"
workflow_dispatch:

concurrency:
group: production-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
uses: ./.github/workflows/wc-deploy-cloudflare-pages.yml
with:
branch: 'main'
gh-app-id: ${{ vars.BOT_APP_ID }}
pr-comment-enabled: false
secrets:
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
gh-app-private-key: ${{ secrets.BOT_PRIVATE_KEY }}
73 changes: 73 additions & 0 deletions .github/workflows/wc-deploy-cloudflare-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: "Deploy Cloudflare Pages"

on:
workflow_call:
inputs:
branch:
required: true
type: string
gh-app-id:
required: true
type: string
pr-comment-enabled:
required: true
type: boolean
secrets:
gh-app-private-key:
required: true
cloudflare-account-id:
required: true
cloudflare-api-token:
required: true

permissions:
contents: read
deployments: write
pull-requests: write

jobs:
deploy-cloudflare-pages:
runs-on: ubuntu-22.04
steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# https://github.com/marketplace/actions/mise-action
- name: mise action
uses: jdx/mise-action@3bc85396a273ed82bba5e53a15174bbf9dba095c # v2.0.2

- name: Install deps
run: bun install

- name: Build
run: bun run build

# https://github.com/marketplace/actions/create-github-app-token
- name: Create GitHub App Token
uses: actions/create-github-app-token@e8e39f73bb84fdf315a015fa3104f314c0a258b4 # v1.8.1
id: app-token
with:
app-id: ${{ inputs.gh-app-id }}
private-key: ${{ secrets.gh-app-private-key }}

# https://github.com/marketplace/actions/cloudflare-pages-github-action
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca # v1.5.0
id: cloudflare-pages
with:
apiToken: ${{ secrets.cloudflare-api-token }}
accountId: ${{ secrets.cloudflare-account-id }}
projectName: nito-docs
directory: ./dist
gitHubToken: ${{ steps.app-token.outputs.token }}
branch: ${{ inputs.branch }}

# https://github.com/marketplace/actions/lighthouse-check
- name: Lighthouse
uses: foo-software/lighthouse-check-action@f78f162ef0ecd48a18244c427959f0b79ef4d553 # v10.0.0
with:
gitHubAccessToken: ${{ steps.app-token.outputs.token }}
locale: ja
prCommentEnabled: ${{ inputs.pr-comment-enabled }}
urls: ${{ steps.cloudflare-pages.outputs.url }}

0 comments on commit d938260

Please sign in to comment.