moonrepo / moon

A build system and monorepo management tool for the web ecosystem, written in Rust.
https://moonrepo.dev/moon
MIT License
2.89k stars 157 forks source link

[feature] Support a `deploy` task type #1698

Open rhuanbarreto opened 1 week ago

rhuanbarreto commented 1 week ago

Is your feature request related to a problem? Please describe.

moon check runs all test and build type tasks. Very useful for local development and CI. But in CD, after we merge to main, I need to add one naming convention in tasks to be called deploy with the following config:

# .moon/tasks/backend.yml
tasks:
  deploy:
    command: docker build && docker push
    platform: system
    type: run
    local: true
    deps:
      - infra-login
      - build-backend
    options:
      persistent: false
      cache: false

Then in the CD pipeline I run moon run :deploy in order to deploy the whole monorepo.

Describe the solution you'd like

It would be good to have one new task type called deploy which assume some defaults. This would simplify a lot for the ones configuring the monorepo. Also a command moon deploy like moon check would be very useful and would make the mental model of using moon very homogeneous, once you could also use the moon deploy command to run a deploy to a development environment locally in addition to CD.

So the same task would be:

# .moon/tasks/backend.yml
tasks:
  deploy:
    command: docker build && docker push
    platform: system
    type: deploy
    deps:
      - infra-login
      - build-backend

And I could run all deploy tasks with moon deploy

Describe alternatives you've considered

Today only alternative is to run moon run :deploy or using filters or relying on naming conventions.

milesj commented 1 week ago

This could maybe be a preset: deploy that sets all the default/necessary options?

rhuanbarreto commented 6 days ago

A preset is good but this also needs to have its own command to help triggering it on CD for example.

milesj commented 6 days ago

moon deploy would basically be the same code as moon run though. I don't really see how they would be different.

rhuanbarreto commented 6 days ago

what could be a filter to target those kind of tasks without having a name convention like moon run :deploy?