Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: デプロイ関連のワークフローを追加 #3

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ concurrency:
cancel-in-progress: true

jobs:
release:
uses: ./.github/workflows/wc-release.yml
deploy:
uses: ./.github/workflows/wc-deploy-cloudflare-pages.yml
with:
project-name: 'asis-quest-staging'
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 }}
26 changes: 26 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Preview"

on:
pull_request:

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
needs: changed
if: needs.changed.outputs.website == 'true'
with:
project-name: 'asis-quest'
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 }}
24 changes: 24 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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:
project-name: 'asis-quest'
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 }}
10 changes: 10 additions & 0 deletions .github/workflows/wc-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
outputs:
actions:
value: ${{ jobs.changed.outputs.actions }}
website:
value: ${{ jobs.changed.outputs.website }}

permissions:
contents: read
Expand All @@ -15,6 +17,7 @@ jobs:
runs-on: ubuntu-22.04
outputs:
actions: ${{ steps.changes.outputs.actions }}
website: ${{ steps.changes.outputs.website }}
steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout
Expand All @@ -28,3 +31,10 @@ jobs:
filters: |
actions:
- '.github/workflows/*.yml'
website:
- 'public/**/*'
- 'src/**/*'
- '.tool-versions'
- 'astro.config.mjs'
- 'package.json'
- 'tsconfig.json'
76 changes: 76 additions & 0 deletions .github/workflows/wc-deploy-cloudflare-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: "Deploy Cloudflare Pages"

on:
workflow_call:
inputs:
project-name:
required: true
type: string
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# https://github.com/marketplace/actions/mise-action
- name: mise action
uses: jdx/mise-action@d6e32c1796099e0f1f3ac741c220a8b7eae9e5dd # v2.0.6

- name: Install deps
run: bun install --frozen-lockfile

- 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@c8f55efbd427e7465d6da1106e7979bc8aaee856 # v1.10.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: ${{ inputs.project-name }}
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@a80267da2e0244b8a2e457a8575fc47590615852 # v12.0.1
with:
gitHubAccessToken: ${{ steps.app-token.outputs.token }}
locale: ja
prCommentEnabled: ${{ inputs.pr-comment-enabled }}
urls: ${{ steps.cloudflare-pages.outputs.url }}
54 changes: 0 additions & 54 deletions .github/workflows/wc-release.yml

This file was deleted.

Loading