Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close PR Trigger should be removed in some cases #23222

Closed
yp05327 opened this issue Mar 1, 2023 · 6 comments
Closed

Close PR Trigger should be removed in some cases #23222

yp05327 opened this issue Mar 1, 2023 · 6 comments
Labels

Comments

@yp05327
Copy link
Contributor

yp05327 commented Mar 1, 2023

Description

I used both push and pull_request in the workflow config yaml file.

on:
  - push
  - pull_request

If you merge a PR, you will get two action tasks:
image

In action_run table, the record is as following:
image

ref name is pr.MergedCommitID, and the event's action is closed

WithRef(pr.MergedCommitID).

It seems that Close PR Event will be triggered, when you merge a PR.
I don't think we need to trigger Close PR Event, as if a PR is closed without merge, this event will also be triggered:
Create a PR and just close it:
image
An action task will start to run:
image
And the action task name will be the latest commit name:
image

If we removed Close PR Trigger, when a PR is merged, the only Push Trigger will work.

Gitea Version

latest

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

build

Database

None

@yp05327 yp05327 changed the title NotifyMergePullRequest should be removed Close PR Trigger should be removed in actions Mar 1, 2023
@wolfogre
Copy link
Member

wolfogre commented Mar 2, 2023

TBH, I noticed this "bug" early on, but didn't know how to fix it.

It's not a good idea to remove the close PR trigger. Think about this, what if I want a workflow to add a comment to a PR automatically when the PR has been closed?

@lunny
Copy link
Member

lunny commented Mar 2, 2023

So the default events for pull_request is only create and sync?

@yp05327
Copy link
Contributor Author

yp05327 commented Mar 2, 2023

@wolfogre
You are right.

I found this document:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
It seems that we can set activity types in github.

Then I changed workflow yaml file:

name: Gitea Actions Demo
run-name: ${{ github.actor }} is testing out Gitea Actions 🚀
on:
  pull_request:
    types: [opened]

jobs:
  Explore-Gitea-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
      - run: echo "🔎 The name   of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "🖥️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}          
      - run: echo "🍏 This job's status is ${{ job.status }}."

It seems that act is not support this:
image

RawOn is defined as a yaml.Node
image

@lunny
Copy link
Member

lunny commented Mar 2, 2023

This maybe fixed by #23037

@yp05327 yp05327 changed the title Close PR Trigger should be removed in actions Close PR Trigger should be removed in some cases Mar 7, 2023
@yp05327
Copy link
Contributor Author

yp05327 commented Mar 7, 2023

It's not a good idea to remove the close PR trigger. Think about this, what if I want a workflow to add a comment to a PR automatically when the PR has been closed?

I think it is possible to remove close PR trigger in some cases as default, such as close PRs, merge PRs(which will trigger close PR event), as if users want to trigger these close PR events, they can add types to customize their needs.

@yp05327
Copy link
Contributor Author

yp05327 commented Apr 25, 2023

Fixed by #23037

@yp05327 yp05327 closed this as completed Apr 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants