YumNumm / ticket-system

https://ticket.yumnumm.dev
2 stars 0 forks source link

自動デプロイ用のWorkflowを組む #8

Open YumNumm opened 1 month ago

YumNumm commented 1 month ago

概要

メモ

参考

name: Deploy Web (Main)
on:
  push:
    branches:
      - main
      - develop
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    steps:
      # https://github.com/actions/checkout
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Set up ssh
        run: |
          mkdir -p ~/.ssh
          echo "${{ secrets.SSH_ID_ED25519 }}" | base64 -d > ~/.ssh/id_ed25519
          chmod 700 ~/.ssh/id_ed25519
          eval $(ssh-agent -s)
          echo "Host github.com \n\tIdentityFile ~/.ssh/id_ed25519\n\tUser git\n\tIdentityiesOnly yes" >> ~/.ssh/config
          ssh-keyscan -H github.com >> ~/.ssh/known_hosts

      - uses: kuhnroyal/flutter-fvm-config-action@v2
        id: fvm-config-action
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
          channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}

      - name: Setup melos
        run: |
          ln -s $FLUTTER_ROOT .fvm/flutter_sdk
          dart pub global activate melos
          melos bootstrap

      - name: build_runner
        run: |
          echo '${{ secrets.ENV }}' | base64 -d > app/.env
          melos generate

      - name: Build web
        working-directory: app
        run: flutter build web --release --wasm

      - name: Publish to Cloudflare Pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: 4270d8a14dfc1f866629099a788c93e2
          projectName: eqmonitor-web
          directory: app/build/web
          # Optional: Enable this if you want to have GitHub Deployments triggered
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
          branch: main
          wranglerVersion: "3"
YumNumm commented 1 month ago

✨✨ Here's an AI-assisted sketch of how you might approach this issue saved by @YumNumm using Copilot Workspace v0.22

Topic
Is there a GitHub Actions Workflow set up to automatically deploy to Cloudflare Pages with the specified configurations?
Before
* No, there is no GitHub Actions Workflow set up to automatically deploy to Cloudflare Pages with the specified configurations. * No workflow file found in the repository for automatic deployment. * No evidence of GitHub Actions configuration in the repository files. * No `main` branch specific deployment setup found. * No Cloudflare Pages project configuration found in the repository files.
After
* Yes, there is now a GitHub Actions Workflow set up to automatically deploy to Cloudflare Pages with the specified configurations. * Added a new workflow file, `deploy.yml`, in the `.github/workflows` directory. * The workflow triggers on push to the `main` branch and can be manually triggered. * The workflow includes steps for checking out the repository, setting up Flutter, building the web app, and deploying to Cloudflare Pages. * The Cloudflare Pages project configuration is set with `projectName: ticket-system`, `accountId: 4270d8a14dfc1f866629099a788c93e2`, and `wranglerVersion: "3"`.
Plan
* `api/.github/workflows/deploy.yml` (ADD) - Create a new GitHub Actions workflow file - Set the workflow to trigger on push to the `main` branch and manual dispatch - Add steps for checking out the repository, setting up Flutter by FVM, install melos and exec melos bootstrap, building the web app, and deploying to Cloudflare Pages - Configure Cloudflare Pages project with `projectName: ticket-system`, `accountId: 4270d8a14dfc1f866629099a788c93e2`, and `wranglerVersion: "3"`
Sketch of implementation
[View the changes](https://copilot-workspace.githubnext.com/YumNumm/ticket-system/issues/8?shareId=bd91be90-ea6a-44bd-b4cc-20567fadef67)
Details
Code analyzed at c847700fa1762aa0d0a5a75b39f5da773818d841