Skip to content

Commit ce18db7

Browse files
authored
[Feature] Add GitLab CI job token (#57)
* add job token * fix phar building
1 parent 2a16950 commit ce18db7

File tree

21 files changed

+189
-74
lines changed

21 files changed

+189
-74
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ jobs:
99
steps:
1010
- uses: actions/checkout@master
1111

12+
- name: Get release
13+
id: get_release
14+
uses: bruceadams/[email protected]
15+
env:
16+
GITHUB_TOKEN: ${{ github.token }}
17+
1218
- name: set MR-Linter version
13-
run: echo "MR_LINTER_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
19+
run: echo "MR_LINTER_VERSION=${{ steps.get_release.outputs.tag_name }}" >> $GITHUB_ENV
1420

1521
- name: composer deps
1622
run: composer install --no-interaction --no-dev --prefer-dist --optimize-autoloader
@@ -26,11 +32,25 @@ jobs:
2632
with:
2733
args: gpg --command-fd 0 --pinentry-mode loopback -u [email protected] --batch --detach-sign --output bin/build/mr-linter.phar.asc bin/build/mr-linter.phar
2834

29-
- name: release phar
30-
uses: fnkr/github-action-ghr@v1
35+
- name: Upload phar
36+
uses: actions/upload-release-asset@v1
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
upload_url: ${{ steps.get_release.outputs.upload_url }}
41+
asset_path: ./bin/build/mr-linter.phar
42+
asset_name: mr-linter.phar
43+
asset_content_type: application/octet-stream
44+
45+
- name: Upload phar.asc
46+
uses: actions/upload-release-asset@v1
3147
env:
32-
GHR_PATH: bin/build
33-
GITHUB_TOKEN: ${{ secrets.MR_LINTER_GITHUB_HTTP_TOKEN }}
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
upload_url: ${{ steps.get_release.outputs.upload_url }}
51+
asset_path: ./bin/build/mr-linter.phar.asc
52+
asset_name: mr-linter.phar.asc
53+
asset_content_type: application/octet-stream
3454

3555
- name: build and publish Docker Image
3656
env:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ This file contains changelogs.
66

77
-----------------------------------------------------------------
88

9+
## [v0.16.1 (2023-08-13)](https://github.com/ArtARTs36/php-merge-request-linter/compare/0.16.0..0.16.1)
10+
11+
## Added
12+
* Support GitLab CI job token
13+
14+
## Fixed
15+
* Fixed phar on "TwigTest not found"
16+
17+
[💾 Assets](https://github.com/ArtARTs36/php-merge-request-linter/releases/tag/0.16.1)
18+
19+
-----------------------------------------------------------------
20+
921
## [v0.16.0 (2023-08-06)](https://github.com/ArtARTs36/php-merge-request-linter/compare/0.15.3..0.16.0)
1022

1123
## Added

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ try:
1818
GITHUB_REF_NAME=${MR_ID}/merge \
1919
./bin/mr-linter lint --debug --metrics
2020

21+
# usage as `make try-phar MR_ID=1`
22+
try-phar: build-phar
23+
GITHUB_ACTIONS=1 \
24+
GITHUB_REPOSITORY=artarts36/php-merge-request-linter \
25+
GITHUB_GRAPHQL_URL=https://api.github.com/graphql \
26+
GITHUB_REF_NAME=${MR_ID}/merge \
27+
./bin/build/mr-linter.phar lint --debug --metrics
28+
2129
# usage as `make try MR_ID=1`
2230
try-docker: docker-build
2331
docker run \
@@ -161,3 +169,8 @@ deptrac-docker: docker-build
161169
artarts36/merge-request-linter "deptrac"
162170

163171
check-docker: lint-docker stat-analyse-docker test-docker deptrac-docker
172+
173+
build-phar:
174+
composer install --no-interaction --no-dev --prefer-dist --optimize-autoloader
175+
cd dev/build/ && composer install
176+
./dev/build/vendor/bin/box compile

box.json.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"check-requirements": false,
2+
"check-requirements": true,
33
"dump-autoload": true,
44
"compactors": [
55
"KevinGH\\Box\\Compactor\\Json",

dev/build/build.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

dev/build/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"require": {
33
"php": "^8.0",
44
"ergebnis/composer-normalize": "^2.15.0",
5-
"humbug/box": "^3.8",
6-
"humbug/php-scoper": "dev-main#0a4e329 as 0.14.2"
5+
"humbug/box": "4.3.8"
76
},
87
"config": {
98
"optimize-autoloader": true,

docs/Builder/ConfigJsonSchema/Generator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public function generate(): JsonSchema
6565
'properties' => [
6666
'token' => [
6767
'type' => 'string',
68-
'description' => 'API Token',
68+
'description' => 'Access Token',
69+
],
70+
'job_token' => [
71+
'type' => 'string',
72+
'description' => 'Job Token',
6973
],
7074
],
7175
],

docs/getting-started.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Examples:
99

1010
Or generate **yaml** file with following command:
1111
```shell
12-
docker run -v "${PWD}:/app/:rw" --user 1000:1000 -it artarts36/merge-request-linter:0.10.0 install
12+
docker run -v "${PWD}:/app/:rw" --user 1000:1000 -it artarts36/merge-request-linter:0.16.1 install
1313
```
1414

1515
Or generate **json** file with following command:
1616
```shell
17-
docker run -v "${PWD}:/app/:rw" --user 1000:1000 -it artarts36/merge-request-linter:0.10.0 install --format=json
17+
docker run -v "${PWD}:/app/:rw" --user 1000:1000 -it artarts36/merge-request-linter:0.16.1 install --format=json
1818
```
1919

2020
When writing a config, look at [JSON Schema](config-schema.md).
@@ -60,14 +60,39 @@ build:
6060
3. Add new step into **.gitlab-ci.yml**
6161
```yaml
6262
mr-lint:
63-
image: artarts36/merge-request-linter:0.8.0
63+
image: artarts36/merge-request-linter:0.16.1
6464
stage: test
6565
only:
6666
- merge_requests
6767
script:
6868
- mr-linter lint
6969
```
7070

71+
You can also use `$CI_JOB_TOKEN` if you don't intend to use comments.
72+
73+
Configs with `$CI_JOB_TOKEN`:
74+
75+
* mr-linter.yaml:
76+
```yaml
77+
ci:
78+
gitlab_ci:
79+
credentials:
80+
job_token: 'env(MR_LINTER_GITHUB_HTTP_TOKEN)'
81+
```
82+
83+
* gitlab-ci.yaml
84+
```yaml
85+
mr-lint:
86+
image: artarts36/merge-request-linter:0.16.1
87+
stage: test
88+
only:
89+
- merge_requests
90+
variables:
91+
MR_LINTER_GITLAB_HTTP_TOKEN: $CI_JOB_TOKEN
92+
script:
93+
- mr-linter lint --debug
94+
```
95+
7196
## Usage with Bitbucket Pipelines
7297

7398
1. Create App Password on `https://bitbucket.org/account/settings/app-passwords/new` with permissions:
@@ -83,7 +108,7 @@ build:
83108
pull-requests:
84109
'**':
85110
- step:
86-
image: "artarts36/merge-request-linter:0.11.0"
111+
image: "artarts36/merge-request-linter:0.16.1"
87112
name: PR Review
88113
script:
89114
- mr-linter lint

docs/rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ Currently is available that rules:
150150
<td>array of strings </td>
151151
</tr>
152152
</tbody>
153-
</t
153+
</table>

mr-linter-config-schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,11 @@
17651765
"properties": {
17661766
"token": {
17671767
"type": "string",
1768-
"description": "API Token"
1768+
"description": "Access Token"
1769+
},
1770+
"job_token": {
1771+
"type": "string",
1772+
"description": "Job Token"
17691773
}
17701774
}
17711775
}

0 commit comments

Comments
 (0)