I’ve got my own instance of Gitea hosted on a computer. Recently, I’ve added a workflow to a repository that triggers whenever a pull request is opened, reopened or synchronized that computes a changelog for that request and adds some information in the form of comments.
This workflow works as a charm whenever anyone opens a PR manually through the web page. However, whenever a PR is opened through a call to the API, actions run twice: Twice the comments are added, twice the workers run at the same time, and there’s twice of everything.
Here’s the action that should trigger once:
name: Project Changelog
run-name: Project Changelog on PR ????
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
Create-Changelog:
runs-on: ubuntu-latest
...
And here’s the code that creates the pull request:
# This is inside a method of a class
self.repo.git.add("*")
self.repo.git.commit("-m", str(description))
self.repo.git.push("--set-upstream", globalSettings.remote_name, branch_name)
# Create pull request
configuration = gitea.Configuration()
configuration.api_key["Authorization"] = f"token {globalSettings.gitea_token}"
configuration.host = globalSettings.gitea_url
api = gitea.RepositoryApi(gitea.ApiClient(configuration))
try:
remote = getattr(self.repo.remotes, globalSettings.remote_name)
remote_url: str = remote.url
except:
raise ValueError(
f"No remote named '{globalSettings.remote_name}' found. Please configure the remote first."
)
# Parse the url to get the owner and the repo name
# The url is in the format: ssh://git@gitserver:2222/owner/repo
# Or in the format: https://gitserver/owner/repo
url = urllib.parse.urlparse(remote_url)
owner, repo = url.path.split("/")[1:]
repo = repo.strip(".git")
body = gitea.CreatePullRequestOption(
title=str(description),
body="",
head=branch_name,
base=start_branch,
)
pr: gitea.PullRequest = api.repo_create_pull_request(owner, repo, body=body)
Does anyone know of what could it be?
I don’t know what to try.
Marc Parcerisa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.