Skip to content

Commit 0ea0cdb

Browse files
authored
ci: unify PAT as token in GitLab CI/CD (#559)
1 parent d339538 commit 0ea0cdb

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

.gitlab/workflows/ci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ semantic-release:
4848
name: node:20.13.1
4949
interruptible: true
5050
rules:
51-
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "serious-scaffold" && $CI_PROJECT_NAME == "ss-python"
51+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "serious-scaffold" && $CI_PROJECT_NAME == "ss-python" && $GITLAB_TOKEN != null
5252
script:
5353
- >
5454
npx
@@ -57,3 +57,5 @@ semantic-release:
5757
-p semantic-release@23
5858
semantic-release
5959
stage: release
60+
variables:
61+
GITLAB_TOKEN: $PAT

.gitlab/workflows/renovate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ renovate:
1616
RENOVATE_BRANCH_PREFIX: renovate-gitlab/
1717
RENOVATE_ENABLED_MANAGERS: '["pep621", "gitlabci", "regex", "pre-commit"]'
1818
RENOVATE_ENDPOINT: $CI_API_V4_URL
19-
RENOVATE_GIT_AUTHOR: Renovate GitLab Bot <gitlab@renovatebot.com>
2019
RENOVATE_OPTIMIZE_FOR_DISABLED: 'true'
2120
RENOVATE_PLATFORM: gitlab
2221
RENOVATE_REPOSITORIES: '["$CI_PROJECT_PATH"]'
2322
RENOVATE_REPOSITORY_CACHE: enabled
2423
RENOVATE_SEMANTIC_COMMIT_TYPE: build
24+
RENOVATE_TOKEN: $PAT

docs/management/config.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ You can set the scope of the variables and secrets to **Repository** or **Organi
7373
1. Set the variable `PDM_PUBLISH_REPO`, the repository (package index) URL to upload the package, default to `https://pypi.org`, the official PyPI.
7474
1. Set the variable `PDM_PUBLISH_USERNAME`, the username to authenticate to the repository (package index), default to `__token__`, used for [API token](https://pypi.org/help/#apitoken).
7575
1. Set the variable `PDM_PUBLISH_PASSWORD` with the **Mask variable** option for security, the password to authenticate to the repository (package index).
76-
1. Renovate authentication:
76+
1. Renovate & semantic-release authentication:
7777

7878
Either [Group access tokens](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html), [Project access tokens](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) or [Personal access tokens](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) can be used. The group or project access tokens are more recommended to avoid the issues and merge requests tied to particular user.
7979

80-
1. Create a [group access token](https://gitlab.com/groups/serious-scaffold/-/settings/access_tokens), [project access token](https://gitlab.com/serious-scaffold/ss-python/-/settings/access_tokens) or [personal access token](https://gitlab.com/-/user_settings/personal_access_tokens) with `api, write_repository` scope.
81-
1. Navigate to the [CI/CD](https://gitlab.com/serious-scaffold/ss-python/-/settings/ci_cd) settings and the **Variables** section. Set the token as variable `RENOVATE_TOKEN` with the **Mask variable** option for security.
80+
1. Create a [group access token](https://gitlab.com/groups/serious-scaffold/-/settings/access_tokens), [project access token](https://gitlab.com/serious-scaffold/ss-python/-/settings/access_tokens) or [personal access token](https://gitlab.com/-/user_settings/personal_access_tokens) with `Maintainer` role and `api, write_repository` scope.
81+
1. Navigate to the [CI/CD](https://gitlab.com/serious-scaffold/ss-python/-/settings/ci_cd) settings and the **Variables** section. Set the token as variable `PAT` with the **Mask variable** option for security.
8282
1. Navigate to the [Pipeline schedules](https://gitlab.com/serious-scaffold/ss-python/-/pipeline_schedules). Create a new schedule with `*/15 0-3 * * 1` as **Interval Pattern** and mark it as **Activated**.
8383

8484
```{note}

template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ semantic-release:
6161
name: node:20.13.1
6262
interruptible: true
6363
rules:
64-
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "{{ repo_namespace }}" && $CI_PROJECT_NAME == "{{ repo_name }}"
64+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "{{ repo_namespace }}" && $CI_PROJECT_NAME == "{{ repo_name }}" && $GITLAB_TOKEN != null
6565
script:
6666
- >
6767
npx
@@ -70,3 +70,5 @@ semantic-release:
7070
-p semantic-release@23
7171
semantic-release
7272
stage: release
73+
variables:
74+
GITLAB_TOKEN: $PAT

template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/renovate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ renovate:
1616
RENOVATE_BRANCH_PREFIX: renovate-gitlab/
1717
RENOVATE_ENABLED_MANAGERS: '["pep621", "gitlabci", "regex", "pre-commit"]'
1818
RENOVATE_ENDPOINT: $CI_API_V4_URL
19-
RENOVATE_GIT_AUTHOR: Renovate GitLab Bot <gitlab@renovatebot.com>
2019
RENOVATE_OPTIMIZE_FOR_DISABLED: 'true'
2120
RENOVATE_PLATFORM: gitlab
2221
RENOVATE_REPOSITORIES: '["$CI_PROJECT_PATH"]'
2322
RENOVATE_REPOSITORY_CACHE: enabled
2423
RENOVATE_SEMANTIC_COMMIT_TYPE: build
24+
RENOVATE_TOKEN: $PAT

template/docs/management/config.md.jinja

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ You can set the scope of the variables and secrets to **Repository** or **Organi
7373
1. Set the variable `PDM_PUBLISH_REPO`, the repository (package index) URL to upload the package, default to `https://pypi.org`, the official PyPI.
7474
1. Set the variable `PDM_PUBLISH_USERNAME`, the username to authenticate to the repository (package index), default to `__token__`, used for [API token](https://pypi.org/help/#apitoken).
7575
1. Set the variable `PDM_PUBLISH_PASSWORD` with the **Mask variable** option for security, the password to authenticate to the repository (package index).
76-
1. Renovate authentication:
76+
1. Renovate & semantic-release authentication:
7777

7878
Either [Group access tokens](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html), [Project access tokens](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) or [Personal access tokens](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) can be used. The group or project access tokens are more recommended to avoid the issues and merge requests tied to particular user.
7979

80-
1. Create a [group access token](https://gitlab.com/groups/{{ repo_namespace }}/-/settings/access_tokens), [project access token](https://gitlab.com/{{ repo_namespace }}/{{ repo_name }}/-/settings/access_tokens) or [personal access token](https://gitlab.com/-/user_settings/personal_access_tokens) with `api, write_repository` scope.
81-
1. Navigate to the [CI/CD](https://gitlab.com/{{ repo_namespace }}/{{ repo_name }}/-/settings/ci_cd) settings and the **Variables** section. Set the token as variable `RENOVATE_TOKEN` with the **Mask variable** option for security.
80+
1. Create a [group access token](https://gitlab.com/groups/{{ repo_namespace }}/-/settings/access_tokens), [project access token](https://gitlab.com/{{ repo_namespace }}/{{ repo_name }}/-/settings/access_tokens) or [personal access token](https://gitlab.com/-/user_settings/personal_access_tokens) with `Maintainer` role and `api, write_repository` scope.
81+
1. Navigate to the [CI/CD](https://gitlab.com/{{ repo_namespace }}/{{ repo_name }}/-/settings/ci_cd) settings and the **Variables** section. Set the token as variable `PAT` with the **Mask variable** option for security.
8282
1. Navigate to the [Pipeline schedules](https://gitlab.com/{{ repo_namespace }}/{{ repo_name }}/-/pipeline_schedules). Create a new schedule with `*/15 0-3 * * 1` as **Interval Pattern** and mark it as **Activated**.
8383

8484
```{note}

0 commit comments

Comments
 (0)