Skip to content

๐Ÿ› Secrets ใŒ env ใซๅพ“ใฃใฆ put ใ•ใ‚Œใฆใ„ใชใ„ใƒใ‚ฐ #68

๐Ÿ› Secrets ใŒ env ใซๅพ“ใฃใฆ put ใ•ใ‚Œใฆใ„ใชใ„ใƒใ‚ฐ

๐Ÿ› Secrets ใŒ env ใซๅพ“ใฃใฆ put ใ•ใ‚Œใฆใ„ใชใ„ใƒใ‚ฐ #68

Workflow file for this run

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
- name: ๐Ÿ”จ Prepare Bun environment
uses: oven-sh/setup-bun@v1
- name: ๐ŸŽ‰ Install project dependencies
run: bun i
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
# `secrets` ใƒ—ใƒญใƒ‘ใƒ†ใ‚ฃใƒผใ‚’ๆŒ‡ๅฎšใ™ใ‚‹ใ‚„ใ‚Šๆ–นใ ใจ, Workers ใฏใกใ‚ƒใ‚“ใจ env ใซๅพ“ใฃใฆใƒ‡ใƒ—ใƒญใ‚คใ•ใ‚Œใ‚‹ใ‘ใฉ,
# Secrets ใฏใชใœใ‹ env ใ‚’็„ก่ฆ–ใ—ใฆ put ใ—ใฆใ—ใพใ†ใฎใงใ“ใ“ใง่‡ชๅ‰ใง put ใ™ใ‚‹.
postCommands: |
wrangler secret put MODE --env ${{ env.MODE }};
wrangler secret put API_MAIL_DKIM_PRIVATE_KEY --env ${{ env.MODE }};
wrangler secret put API_DISCORD_WEBHOOK_URL_CONTACT --env ${{ env.MODE }};
wrangler secret put API_DISCORD_WEBHOOK_MENTION_ID --env ${{ env.MODE }};
wrangler secret put API_CONTACT_MANIFEST --env ${{ env.MODE }};
wrangler secret put API_ASSETS_ENDPOINT --env ${{ env.MODE }};
wrangler secret put API_ASSETS_ACCESS_KEY --env ${{ env.MODE }};
env:
MODE: ${{ env.MODE }}
API_MAIL_DKIM_PRIVATE_KEY: ${{ secrets.API_MAIL_DKIM_PRIVATE_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 }}