---
version: '3'

tasks:
  bridge:
    deps:
      - bridge:github
      - bridge:gitlab

    run: once
  bridge:github:
    deps:
      - :install:software:git-bug
    run: once
    cmds:
      - git bug bridge configure --name="$(jq -r '.name' package.json)" --target=github
        --url="$(jq -r '.blueprint.repository.github' package.json)" --token="$GITHUB_TOKEN"
    status:
      - '[ -z "$GITHUB_TOKEN" ]'

  bridge:gitlab:
    deps:
      - :install:software:git-bug
    run: once
    cmds:
      - git bug bridge configure --name="$(jq -r '.name' package.json)" --target=gitlab
        --url="$(jq -r '.blueprint.repository.gitlab' package.json)" --token="$GITLAB_TOKEN" --base-url=https://gitlab.com/
    status:
      - '[ -z "$GITLAB_TOKEN" ]'

  pull:
    deps:
      - bridge
      - :git:remotes
      - :install:software:git-bug
    cmds:
      - git bug pull all

  push:
    deps:
      - bridge
      - :git:remotes
      - :install:software:git-bug
    cmds:
      - git bug push all

  webui:
    deps:
      - bridge
      - pull
      - :install:software:git-bug
    cmds:
      - git bug webui
