Jetbrains Spaces Automation

maymeow

Meow

Posted on December 10, 2020

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?

💖 💪 🙅 🚩
maymeow
Meow

Posted on December 10, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related