⬆️ GitHub Actions の Bun のバージョンを上げた #80
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: cloudflare | |
on: | |
push: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ (github.ref == 'refs/heads/prod' && 'production') || 'preview' }} | |
if: contains(github.event.head_commit.message, '[skip ci]') == false | |
env: | |
MODE: ${{ (github.ref == 'refs/heads/prod' && 'production') || 'preview' }} | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: 📸 Calculate commit hash | |
id: sha | |
uses: pr-mpt/actions-commit-hash@v3 | |
- uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: 🎉 Install project dependencies | |
run: bun i | |
- name: 📦 Download assets | |
run: bun :client assets:dl | |
env: | |
CLIENT_SCRIPT_ASSETS_API_ENDPOINT: ${{ secrets.CLIENT_SCRIPT_ASSETS_API_ENDPOINT }} | |
CLIENT_SCRIPT_ASSETS_API_ACCESS_TOKEN: ${{ secrets.CLIENT_SCRIPT_ASSETS_API_ACCESS_TOKEN }} | |
CLIENT_SCRIPT_ASSETS_API_REFERER: ${{ secrets.CLIENT_SCRIPT_ASSETS_API_REFERER }} | |
- name: 🏗️ Generate static files | |
run: bun run build | |
env: | |
CLIENT_MICROCMS_SERVICE_DOMAIN: ${{ secrets.CLIENT_MICROCMS_SERVICE_DOMAIN }} | |
CLIENT_MICROCMS_API_KEY: ${{ secrets.CLIENT_MICROCMS_API_KEY }} | |
PUBLIC_CLIENT_CF_TURNSTILE_SITE_KEY: ${{ secrets.PUBLIC_CLIENT_CF_TURNSTILE_SITE_KEY }} | |
PUBLIC_CLIENT_API_ENDPOINT: ${{ secrets.PUBLIC_CLIENT_API_ENDPOINT }} | |
PUBLIC_CLIENT_API_ACCESS_TOKEN: ${{ secrets.PUBLIC_CLIENT_API_ACCESS_TOKEN }} | |
- name: 🚀 Deploy to Cloudflare Pages | |
id: cloudflare_pages_deploy | |
uses: cloudflare/pages-action@v1 | |
with: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN_PAGES }} | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
projectName: 9u3rcus-web-client | |
directory: ./client/dist | |
env: | |
NODE_VERSION: 21 | |
- name: 🚀 Deploy to Cloudflare Workers | |
uses: cloudflare/[email protected] | |
with: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN_WORKERS }} | |
command: "deploy --minify src/index.ts --env ${{ env.MODE }}" | |
workingDirectory: ./api | |
# NOTE: これは secrets にしか適用されない. command の env は引数で渡す. 🤔 | |
environment: ${{ env.MODE }} | |
secrets: | | |
MODE | |
API_RESEND_API_KEY | |
API_DISCORD_WEBHOOK_URL_CONTACT | |
API_DISCORD_WEBHOOK_MENTION_ID | |
API_CONTACT_MANIFEST | |
API_ASSETS_ENDPOINT | |
API_ASSETS_ACCESS_KEY | |
env: | |
MODE: ${{ env.MODE }} | |
API_RESEND_API_KEY: ${{ secrets.API_RESEND_API_KEY }} | |
API_DISCORD_WEBHOOK_URL_CONTACT: ${{ secrets.API_DISCORD_WEBHOOK_URL_CONTACT }} | |
API_DISCORD_WEBHOOK_MENTION_ID: ${{ secrets.API_DISCORD_WEBHOOK_MENTION_ID }} | |
API_CONTACT_MANIFEST: ${{ secrets.API_CONTACT_MANIFEST }} | |
API_ASSETS_ENDPOINT: ${{ secrets.API_ASSETS_ENDPOINT }} | |
API_ASSETS_ACCESS_KEY: ${{ secrets.API_ASSETS_ACCESS_KEY }} |