rails-8-0-db-structure #13
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: rails-8-0-db-structure | |
on: | |
schedule: | |
# Schedule: Runs at 9:00 AM and 1:00 PM Asia/Tokyo time (UTC+9) on weekdays (Monday to Friday). | |
- cron: "0 0,4 * * mon-fri" | |
workflow_dispatch: | |
jobs: | |
build-and-deploy-erd: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: samples/rails-8-0-db-structure | |
permissions: | |
contents: read | |
deployments: write | |
# NOTE: for db tasks. | |
services: | |
postgres: | |
image: postgres:17.2 | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
POSTGRES_PASSWORD: password | |
steps: | |
- uses: actions/checkout@v4 | |
# NOTE: for `bin/rails` command. | |
- name: Setup Ruby for samples/rails-8-0-db-structure | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
working-directory: samples/rails-8-0-db-structure | |
# NOTE: Setting `SCHEMA_FORMAT=ruby` overrides `db:schema:dump` behavior | |
# see https://github.com/rails/rails/blob/v8.0.1/activerecord/lib/active_record/railties/databases.rake#L448 | |
- name: Generate db/schema.rb | |
env: | |
SCHEMA_FORMAT: ruby | |
run: bin/rails db:create db:migrate db:schema:dump | |
- name: Generate ER Diagrams | |
run: npx @liam-hq/cli erd build --input db/schema.rb --format schemarb | |
# For check | |
- name: ls -alF dist | |
run: ls -alF dist | |
# NOTE: For deploy, comment-in. | |
# see also other .github/workflows/ files. | |
# - name: Deploy ERD to Cloudflare Pages | |
# uses: cloudflare/wrangler-action@v3 | |
# with: | |
# apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN_SAMPLE_PRISMA }} | |
# accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID_SAMPLE_PRISMA }} | |
# workingDirectory: samples/prisma-with-cloudflare-pages | |
# command: pages deploy ./dist --project-name=prisma-with-cloudflare-pages | |
# gitHubToken: ${{ secrets.GITHUB_TOKEN }} |