DEV Community

Meow
Meow

Posted on

2

Jetbrains Spaces Automation

Jetbrains spaces is from yesterday GA. I'am long time user of Gitlab and its CI which i really like but wanted to try another product so i tried Github and don't like their implementation of CI (github actions). So yesterday i tried Spaces automation and IMO it is easy to rewrite configuration from gitlab to spaces.

Here is as example my script which i use to deploy my webpage:

stages:
  - build
  - deploy

# Build site with hugo and upload cache and artifacts
pages:
  stage: build
  image: pkg.cloud.themaymeow.com/ci/hugo:extended-v0.75.1
  cache:
    key: themaymeow-com-build
    paths:
      - public
    policy: push
  script:
    - hugo --config ./production.config.toml --enableGitInfo
  artifacts:
    expire_in: 1 week
    paths:
      - public
  only:
    - master
  tags:
    - docker
    - digitalocean

deploy to azure:
  stage: deploy
  image: maymeow/minio-cli
  cache:
    key: themaymeow-com-build
    paths:
      - public
    policy: pull
  dependencies:
    - pages
  script:
    - mc config host add cdn https://storage.googleapis.com $ACCESS $SECRET --api s3v4
    - cd public
    - mc cp -r . cdn/www.themaymeow.com
    - mc ls cdn/www.themaymeow.com
  only:
    - master
  tags:
    - docker
    - digitalocean
Enter fullscreen mode Exit fullscreen mode

and following is rewritten to spaces automation

/**
* JetBrains Space Automation
* This Kotlin-script file lets you automate build activities
* For more info, see https://www.jetbrains.com/help/space/automation.html
*/

job("Build page and deploy") {
    startOn {
        gitPush { enabled = true }
    }

    // compile page
    container("compiled.registry.jetbrains.space/p/blog/containers/hugo:0.0.1") {
        shellScript {
            content = """
                hugo --config ./production.config.toml --enableGitInfo
                mv ./public /mnt/space/share
            """
        }
    }

    // publish page to cloud
    container("maymeow/minio-cli") {
        env["KEY"] = Secrets("key")
        env["SECRET"] = Secrets("secret")
        shellScript {
            content = """
                mc config host add cdn https://storage.googleapis.com ${'$'}KEY ${'$'}SECRET --api s3v4
                cd /mnt/space/share/public
                mc cp -r . cdn/www.themaymeow.com
                mc ls cdn/www.themaymeow.com
            """
        }
    }

    // clean
    container("alpine") {
        shellScript {
            content = "rm -r ./public /mnt/space/share/public"
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

So what do you think?

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
alfredosalzillo profile image
Alfredo Salzillo

It looks so Jenkins style

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post