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

Workflow Definition for local development #6

Open
otiai10 opened this issue Jul 16, 2024 · 0 comments
Open

Workflow Definition for local development #6

otiai10 opened this issue Jul 16, 2024 · 0 comments

Comments

@otiai10
Copy link
Owner

otiai10 commented Jul 16, 2024

version: 0
runtime:
  runs_on: local
  prerequisite:
    command:
      - gcloud
      - go
      - npm
      - curl
    num_cpu:
      min: 2
      # max: 4
    memory_gb:
      min: 4
      # max: 8

include:
  - secrets.local.yaml
  - too.local.extends.yaml
# must_include:
#   - xxx
#   - yyy

env:
  PROJECT_ID: triax-football
  DATASTORE_PROJECT_ID: triax-football
  DATASTORE_DATASET: triax-football
  DATASTORE_EMULATOR_HOST: localhost:8081
  DATASTORE_EMULATOR_HOST_PATH: localhost:8081/datastore
  DATASTORE_HOST: http://localhost:8081

variable:
  DATE:
    use: bash
    value: $(date '+%Y-%m%d-%H%M%S')
    collect: stdout

prep:
  steps:
  - name: devdataのディレクトリをつくっておく
    run: mkdir -p ./devdata
  - name: Datastore から Google Cloud Storage に、実データをエクスポート
    run: |
      gcloud datastore export \
        gs://${PROJECT_ID}.appspot.com/datastore-export/${DATE} \
        --project=${PROJECT_ID}
  - name: ねんのために5秒待つ
    run: sleep 5
  - name: Google Cloud Storage からデータをダウンロード
    run: |
      gcloud storage cp -r \
        gs://${PROJECT_ID}.appspot.com/datastore-export/${DATE} \
        ./devdata \
        --project=${PROJECT_ID}

execute:
  jobs:
  - name: Datastore エミュレータを起動
    label: datastore
    run: gcloud beta emulators datastore start --data-dir=./devdata/${DATE} --project=${PROJECT_ID}
  - name: しょうがないのでAPIで突っ込む
    label: import
    run: |
      curl -X POST http://${DATASTORE_EMULATOR_HOST}/v1/projects/${PROJECT_ID}:import \
      -H 'Content-Type: application/json' \
      -d "{\"input_url\": \"${PWD}/devdata/${DATE}/${DATE}.overall_export_metadata\"}"
  - name: APIサーバ起動
    label: api
    run: go run main.go
  - name: フロントエンドdevサーバ起動
    label: frontend
    run: npm run dev

post:
  steps:
  - name: Clean up process
    run: pkill datastore
    ignore_error: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant