Allow to set a token from input (#1)
Reviewed-on: #1 Co-authored-by: Julien Fastré <julien.fastre@champs-libres.coop> Co-committed-by: Julien Fastré <julien.fastre@champs-libres.coop>
This commit is contained in:
parent
8f676ccb15
commit
3e47a24f8d
32
README.md
32
README.md
@ -1,5 +1,35 @@
|
|||||||
# Gitea action to Create a Pull Request
|
# Gitea action to Create a Pull Request
|
||||||
|
|
||||||
Gitea action to create a pull request.
|
Gitea action to create a pull request. This action is not github action compatible.
|
||||||
|
|
||||||
Inspired by https://github.com/peter-evans/create-pull-request, but without the ability to commit the changes.
|
Inspired by https://github.com/peter-evans/create-pull-request, but without the ability to commit the changes.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup Go
|
||||||
|
uses: https://github.com/actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
|
||||||
|
# ... do something with your code
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Use Go Action
|
||||||
|
id: use-go-action
|
||||||
|
uses: https://gitea.champs-libres.be/julienfastre/action-create-pr@main
|
||||||
|
with:
|
||||||
|
assignees: julienfastre
|
||||||
|
base: master
|
||||||
|
labels: bug, invalid, something else
|
||||||
|
|
||||||
|
```
|
||||||
|
@ -4,6 +4,9 @@ runs:
|
|||||||
using: 'go'
|
using: 'go'
|
||||||
main: 'main.go'
|
main: 'main.go'
|
||||||
inputs:
|
inputs:
|
||||||
|
token:
|
||||||
|
description: 'Access token which allow to create pull requests'
|
||||||
|
default: ${{ github.token }}
|
||||||
title:
|
title:
|
||||||
required: false
|
required: false
|
||||||
description: The title of the pull request
|
description: The title of the pull request
|
||||||
@ -23,6 +26,7 @@ inputs:
|
|||||||
head:
|
head:
|
||||||
description: >
|
description: >
|
||||||
The pull request head branch (the one within the new code is developed).
|
The pull request head branch (the one within the new code is developed).
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
pull-request-number:
|
pull-request-number:
|
||||||
description: 'The pull request number'
|
description: 'The pull request number'
|
||||||
|
5
main.go
5
main.go
@ -69,8 +69,9 @@ func main() {
|
|||||||
githubactions.Fatalf("could not get context: %v", err.Error())
|
githubactions.Fatalf("could not get context: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
token := os.Getenv("GITHUB_TOKEN")
|
token := githubactions.GetInput("token")
|
||||||
fmt.Printf("Api url is %v\n", ctx.ServerURL)
|
fmt.Printf("Api url is %v\n", ctx.ServerURL)
|
||||||
|
fmt.Printf("Debug: token length is %d characters\n", len(token))
|
||||||
|
|
||||||
config, err := ParseActionConfig(*ctx)
|
config, err := ParseActionConfig(*ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -125,7 +126,7 @@ func (a *Agent) ExistingOpenPullRequest(config CreatePrConfig) (bool, *gitea.Pul
|
|||||||
gitea.ListPullRequestsOptions{State: gitea.StateOpen, ListOptions: gitea.ListOptions{Page: currentPage}})
|
gitea.ListPullRequestsOptions{State: gitea.StateOpen, ListOptions: gitea.ListOptions{Page: currentPage}})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, fmt.Errorf("error while listing all exisiting open pull requests: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pull := range pulls {
|
for _, pull := range pulls {
|
||||||
|
Loading…
Reference in New Issue
Block a user