Skip to content

Commit

Permalink
docs(README): 📝 add section on using ci_job_token
Browse files Browse the repository at this point in the history
  • Loading branch information
dannylongeuay authored and christophwitzko committed May 15, 2024
1 parent 96a103b commit b11b169
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ You can set the GitLab token via the `GITLAB_TOKEN` environment variable or the

.gitlab-ci.yml
```yml
stages:
stages:
# other stages
- release
Expand All @@ -119,6 +119,34 @@ release:
- semantic-release # Add --allow-no-changes if you want to create a release for each push
```

#### Job Token
If you do not provide a PAT the [job token](https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html) will be used.
This restricted token can create releases but not read commits. The [git strategy](https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-strategy)
must be set to clone so that we can read the commits from the repository. See example below

.gitlab-ci.yml
```yml
variables:
GIT_STRATEGY: clone
stages:
# other stages
- release
release:
image:
name: registry.gitlab.com/go-semantic-release/semantic-release:latest
entrypoint: [""]
stage: release
# when: manual # Add this if you want to manually create releases
only:
- master
script:
- semantic-release
# - semantic-release --allow-no-changes # create a release for each push
# - semantic-release --provider gitlab --provider-opt log_order=ctime # traverse commits by committer time (commits in merge requests will affect the calculated version)
```

### Releasing a Go application with GitLab CI
The full example can be found at https://gitlab.com/go-semantic-release/example-go-application.

Expand Down

0 comments on commit b11b169

Please sign in to comment.