Commit 5a178931 authored by FulcrandG's avatar FulcrandG
Browse files

Testing release job

parent e844d6df
Loading
Loading
Loading
Loading
+29 −16
Original line number Diff line number Diff line
@@ -46,21 +46,34 @@ pages:
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)
    -     OUT=$(curl https://gitlab.com/api/v4/projects/go2scale%2Fhub/releases/${JOB}-${VERSION} | grep '{"message":"403 Forbidden"}')
    -     if [[ $? -eq 0 ]]; then
    -       echo "no release for the version ${VERSION}"
    -       curl --header 'Content-Type: application/json' --header "PRIVATE-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'", "filepath": "jobs/'${JOB}/${JOB}.yml'", "link_type":"other" }] } }' \
              --request POST https://gitlab.com/api/v4/projects/go2scale%2Fhub/releases
    -     else
    -       echo "release ${VERSION} exists"
    -     fi
    -   done
    - done
  script: >
    for JOB in jobs/*; do
      JOB=$(basename ${JOB})
      for VERSION in jobs/${JOB}/versions/*; do
        VERSION=$(basename ${VERSION} .md)
        OUT=$(curl https://gitlab.com/api/v4/projects/go2scale%2Fhub/releases/${JOB}-${VERSION} | grep '{"message":"403 Forbidden"}')
        if [[ $? -eq 0 ]]; then
          echo "no release for the version ${VERSION}"
          curl --header 'Content-Type: application/json' --header "PRIVATE-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\",
                      \"filepath\": \"/jobs/${JOB}/${JOB}.yml\",
                      \"link_type\":\"other\"
                    }
                  ]
                }
              }"
            --request POST https://gitlab.example.com/api/v4/projects/go2scale%2Fhub/releases
        else
          echo "release ${VERSION} exists"
        fi
      done
    done
  # rules:
  #   - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
 No newline at end of file