8000 docs: update gitlab and github ci tutorials · edvm/commitizen@061f47c · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 061f47c

Browse files
woileLee-W
authored andcommitted
docs: update gitlab and github ci tutorials
1 parent 3b07f53 commit 061f47c

File tree

2 files changed

+23
-37
lines changed

2 files changed

+23
-37
lines changed

docs/tutorials/github_actions.md

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,24 @@ name: Bump version
1616
on:
1717
push:
1818
branches:
19-
- master # another branch could be specified here
19+
- master
2020

2121
jobs:
22-
build:
22+
bump-version:
2323
if: "!startsWith(github.event.head_commit.message, 'bump:')"
2424
runs-on: ubuntu-latest
25-
strategy:
26-
matrix:
27-
python-version: ['3.x']
25+
name: "Bump version and create changelog with commitizen"
2826
steps:
29-
- uses: actions/checkout@v2
30-
with:
31-
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
32-
fetch-depth: 0
33-
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v1
35-
with:
36-
python-version: ${{ matrix.python-version }}
37-
- name: Install dependencies
38-
run: |
39-
python --version
40-
python -m pip install -U commitizen
41-
- name: Create bump
42-
run: |
43-
git config --local user.email "action@github.com"
44-
git config --local user.name "GitHub Action"
45-
cz bump --yes
46-
- name: Push changes
47-
uses: Woile/github-push-action@master
48-
with:
49-
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
50-
tags: "true"
27+
- name: Check out
28+
uses: actions/checkout@v2
29+
with:
30+
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
31+
fetch-depth: 0
32+
- name: Create bump and changelog
33+
uses: commitizen-tools/commitizen-action@master
34+
with:
35+
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
36+
5137
```
5238

5339
Push to master and that's it.

docs/tutorials/gitlab_ci.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
### Create a new release using GitLab CI
1+
## Create a new release using GitLab CI
22

33
For this example, we have a `python/django` application and `Docker` as a containerization tool.
44

5-
*Goal*: Bump a new version every time that a change occurs on the `master` branch. The bump should be executed automatically by the `CI` process.
5+
_Goal_: Bump a new version every time that a change occurs on the `master` branch. The bump should be executed automatically by the `CI` process.
66

7-
#### Development Workflow:
7+
### Development Workflow
88

99
1. A developer creates a new commit on any branch (except `master`)
1010
2. A developer creates a merge request (MR) against `master` branch
1111
3. When the `MR` is merged into master, the 2 stages of the CI are executed
1212
4. For simplification, we store the software version in a file called `VERSION`. You can use any file that you want as `commitizen` supports it.
1313
5. The commit message executed automatically by the `CI` must include `[skip-ci]` in the message; otherwise, the process will generate a loop. You can define the message structure in [commitizen](https://commitizen-tools.github.io/commitizen/bump/) as well.
1414

15-
#### Gitlab Configuration:
15+
### Gitlab Configuration
1616

1717
To be able to change files and push new changes with `Gitlab CI` runners, we need to have a `ssh` key and configure a git user.
1818

@@ -40,15 +40,15 @@ If you have more projects under the same organization, you can reuse the deploy
4040

4141
tip: If the CI raise some errors, try to unprotected the private key.
4242

43-
#### Defining GitLab CI Pipeline
43+
### Defining GitLab CI Pipeline
4444

4545
1. Create a `.gitlab-ci.yaml` file that contains `stages` and `jobs` configurations. You can find more info [here](https://docs.gitlab.com/ee/ci/quick_start/).
4646

4747
2. Define `stages` and `jobs`. For this example, we define two `stages` with one `job` each one.
48-
* Test the application.
49-
* Auto bump the version. This means changing the file/s that reflects the version, creating a new commit and git tag.
48+
- Test the application.
49+
- Auto bump the version. This means changing the file/s that reflects the version, creating a new commit and git tag.
5050

51-
#### Stages and Jobs
51+
### Stages and Jobs
5252

5353
```yaml
5454
image: docker:latest
@@ -76,7 +76,7 @@ auto-bump:
7676
stage: auto-bump
7777
image: python:3.6
7878
before_script:
79-
- 'which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )'
79+
- "which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )"
8080
- eval `ssh-agent -s`
8181
- echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null # add ssh key
8282
- pip3 install -U Commitizen # install commitizen
@@ -102,7 +102,7 @@ auto-bump:
102102
- master
103103
artifacts:
104104
paths:
105-
- variables
105+
- variables
106106
```
107107
108108
So, every time that a developer push to any branch, the `test` job is executed. If the branch is `master` and the test jobs success, the `auto-bump` takes place.

0 commit comments

Comments
 (0)
0