Skip to content

Commit dd01186

Browse files
authored
Merge pull request #33 from eksrvb/feature/pr-query-with-pr-number
add pr query to github api
2 parents 936a274 + 0d9b532 commit dd01186

File tree

7 files changed

+623
-74
lines changed

7 files changed

+623
-74
lines changed

.github/workflows/branchPR.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
run: |
2626
wget https://github.com/eksrvb/awesome-ci/releases/latest/download/awesome-ci
2727
chmod +x awesome-ci
28+
- name: debugging git
29+
run: |
30+
echo "git name-rev HEAD: $(git name-rev HEAD)"
31+
echo "git log -1 --pretty=format:"%s": $(git log -1 --pretty=format:"%s")"
32+
echo "git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@': $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
2833
- name: set build Infos
2934
run: ./awesome-ci getBuildInfos
3035
env:

docs/commands/getBuildInfos.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ nav_order: 2
1111
awesome-ci createRelease [subcommand-option]
1212
```
1313

14-
| Subcommand option | Description |
15-
| ------------------- | ----------------------------------------------------------------------------- |
16-
| `-version` | overrides any version from git and patches the given string. |
17-
| `-patchLevel` | overrides the patchLevel. make shure our following the alias definition. |
18-
| `-format` | pastes the required output to the console. This can be extracted to variables |
14+
| Subcommand option | Description |
15+
| ----------------- | ----------------------------------------------------------------------------- |
16+
| `-version` | overrides any version from git and patches the given string. |
17+
| `-patchLevel` | overrides the patchLevel. make shure our following the alias definition. |
18+
| `-format` | pastes the required output to the console. This can be extracted to variables |
1919

2020
### -version
2121

@@ -46,6 +46,7 @@ Current release version: 1.0.0
4646
Patch level: feature
4747
Possible new release version: 1.1.0
4848
```
49+
4950
```bash
5051
awesome-ci getBuildInfos -patchLevel feature -version 1.0.0 -format "pr,next_version"
5152
# Output:
@@ -54,19 +55,21 @@ awesome-ci getBuildInfos -patchLevel feature -version 1.0.0 -format "pr,next_ver
5455

5556
### Special to github actions
5657

57-
With a github action, all available information is always set as environment variables.
58+
With a github action, all available information is always set as environment variables. Once set the Variables ale awailable in all steps and runners.
5859

5960
```bash
6061
#### Setting Env variables:
61-
PR=17
62-
ORGA=eksrvb
63-
REPO=playground
64-
VERSION=0.4.4
65-
NEXT_VERSION=0.4.5
62+
ACI_PR=17
63+
ACI_ORGA=eksrvb
64+
ACI_REPO=playground
65+
ACI_BRANCH=bugfix/test-pr
66+
ACI_PATCH_LEVEL=bugfix
67+
ACI_VERSION=0.4.4
68+
ACI_NEXT_VERSION=0.4.5
6669

6770
#### Info output:
6871
Pull Request: 17
6972
Current release version: 0.4.4
7073
Patch level: bugfix
7174
Possible new release version: 0.4.5
72-
```
75+
```

gitOnlineController/gitOnlineController.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ func GetPrNumberForBranch(branch string) int {
1313
return 0
1414
}
1515

16+
// GetPrNumberForBranch
17+
func GetPrInfos(prNumber int) (prInfos models.GitHubPullRequest, err error) {
18+
switch CiEnvironment.GitType {
19+
case "github":
20+
prInfos, err = github_getPrInfos(prNumber)
21+
}
22+
return
23+
}
24+
1625
// GetLatestReleaseVersion
1726
func GetLatestReleaseVersion() string {
1827
switch CiEnvironment.GitType {

gitOnlineController/github.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ func github_getPrNumberForBranch(branch string) int {
2828
}
2929
}
3030

31+
func github_getPrInfos(prNumber int) (prInfos models.GitHubPullRequest, err error) {
32+
url := fmt.Sprintf("%srepos/%s/pulls/%d", CiEnvironment.GitInfos.ApiUrl, CiEnvironment.GitInfos.FullRepo, prNumber)
33+
respBytes := newGitHubGetRequestUnmapped(url)
34+
err = json.Unmarshal(respBytes, &prInfos)
35+
return
36+
}
37+
3138
func github_getLatestReleaseVersion() string {
3239
url := fmt.Sprintf("%srepos/%s/releases/latest", CiEnvironment.GitInfos.ApiUrl, CiEnvironment.GitInfos.FullRepo)
3340
result := newGitHubGetRequest(url, CiEnvironment.GitInfos.ApiToken)

0 commit comments

Comments
 (0)