Update .gitlab-ci.yml file
Showing
1 changed file
with
25 additions
and
0 deletions
.gitlab-ci.yml
0 → 100644
| 1 | # This file is a template, and might need editing before it works on your project. | ||
| 2 | # To contribute improvements to CI/CD templates, please follow the Development guide at: | ||
| 3 | # https://docs.gitlab.com/ee/development/cicd/templates.html | ||
| 4 | # This specific template is located at: | ||
| 5 | # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Composer.gitlab-ci.yml | ||
| 6 | |||
| 7 | # Publishes a tag/branch to Composer Packages of the current project | ||
| 8 | publish: | ||
| 9 | image: curlimages/curl:latest | ||
| 10 | stage: build | ||
| 11 | variables: | ||
| 12 | URL: "$CI_SERVER_PROTOCOL://$CI_SERVER_HOST:$CI_SERVER_PORT/api/v4/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN" | ||
| 13 | script: | ||
| 14 | - version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG") | ||
| 15 | - insecure=$([ "$CI_SERVER_PROTOCOL" = "http" ] && echo "--insecure" || echo "") | ||
| 16 | - response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL) | ||
| 17 | - code=$(echo "$response" | tail -n 1) | ||
| 18 | - body=$(echo "$response" | head -n 1) | ||
| 19 | # Output state information | ||
| 20 | - if [ $code -eq 201 ]; then | ||
| 21 | echo "Package created - Code $code - $body"; | ||
| 22 | else | ||
| 23 | echo "Could not create package - Code $code - $body"; | ||
| 24 | exit 1; | ||
| 25 | fi |
-
Please register or sign in to post a comment