Commit 5df7b5e0 authored by Thomas Boni's avatar Thomas Boni
Browse files

Merge branch '65-automate-tag-generation-in-ci' into 'latest'

Resolve "Automate tag generation in CI"

Closes #65

See merge request go2scale/hub!37
parents 9be64ace fb063757
Loading
Loading
Loading
Loading
+31 −2
Original line number Diff line number Diff line
stages:
  - static_tests
  - build
  - production
  - deployment

ci_linter:
  image: golang:1.15.2-alpine3.12
@@ -30,7 +30,7 @@ documentation:
    - public/

pages:
  stage: production
  stage: deployment
  script:
    - echo 'Deploying on Gitlab pages'
  needs:
@@ -41,3 +41,32 @@ pages:
    - public
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

# See https://docs.gitlab.com/ee/api/releases/
# We can only control the link to the hub, the release is still storing the source code
release:
  image: curlimages/curl:7.72.0
  stage: deployment
  script: >
    for JOB in jobs/*; do
      JOB=$(basename ${JOB})
      for VERSION in jobs/${JOB}/versions/*; do
        VERSION=$(basename ${VERSION} .md)
        curl --header 'Content-Type: application/json' --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
          --data "{ \
              \"name\": \"${JOB}-${VERSION}\", \
              \"tag_name\": \"${JOB}-${VERSION}\", \
              \"description\": \"$(cat jobs/${JOB}/versions/${VERSION}.md)\", \
              \"assets\": { \
                \"links\": [ \
                  { \"name\": \"Hub link\", \
                    \"url\": \"https://jobs.go2scale.io/${VERSION}/${JOB}.yml\" \
                  } \
                ] \
              } \
            }" \
          --request POST https://gitlab.com/api/v4/projects/go2scale%2Fhub/releases
      done
    done
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
 No newline at end of file