1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00
gitea/services
Brad Nabholz 950c93a66a
Actions: Use default branch as ref when a branch/tag delete occurs (#23910)
Currently using the tip of main
(2c585d62a4) and when deleting a branch
(and presumably tag, but not tested), no workflows with `on: [delete]`
are being triggered. The runner isn't being notified about them. I see
this in the gitea log:

`2023/04/04 04:29:36 ...s/notifier_helper.go:102:Notify() [E] an error
occurred while executing the NotifyDeleteRef actions method:
gitRepo.GetCommit: object does not exist [id: test, rel_path: ]`

Understandably the ref has already been deleted and so `GetCommit`
fails. Currently at
https://github.com/go-gitea/gitea/blob/main/services/actions/notifier_helper.go#L130,
if the ref is an empty string it falls back to the default branch name.
This PR also checks if it is a `HookEventDelete` and does the same.
Currently `${{ github.ref }}` would be equivalent to the deleted branch
(if `notify()` succeded), but this PR allows `notify()` to proceed and
also aligns it with the GitHub Actions behavior at
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete:

`$GITHUB_REF` / `${{ github.ref }}` => Default branch (main/master)
`$GITHUB_SHA` / `${{ github.sha }}` => Last commit on default branch

If the user needs the name of the deleted branch (or tag), it is
available as `${{ github.event.ref }}`.

There appears to be no way for the user to get the tip commit SHA of the
deleted branch (GitHub does not do this either).

N.B. there may be other conditions other than `HookEventDelete` where
the default branch ref needs swapped in, but this was sufficient for my
use case.
2023-04-06 20:37:08 -04:00
..
actions Actions: Use default branch as ref when a branch/tag delete occurs (#23910) 2023-04-06 20:37:08 -04:00
agit add user rename endpoint to admin api (#22789) 2023-03-14 03:45:21 -04:00
asymkey Add context cache as a request level cache (#22294) 2023-02-15 21:37:34 +08:00
attachment Preserve file size when creating attachments (#23406) 2023-03-12 03:48:07 -04:00
auth Don't apply the group filter when listing LDAP group membership if it is empty (#23745) 2023-03-29 17:54:36 +08:00
automerge Add force_merge to merge request and fix checking mergable (#23010) 2023-02-21 08:42:07 -06:00
context Use User.ID instead of User.Name in ActivityPub API for Person IRI (#23823) 2023-04-04 10:08:23 +08:00
convert Add activity feeds API (#23494) 2023-04-04 21:35:31 +08:00
cron Add Cargo package registry (#21888) 2023-02-05 18:12:31 +08:00
externalaccount Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
forms Add Swift package registry (#22404) 2023-03-13 15:28:39 -05:00
gitdiff Fix broken code editor diff preview (#23307) 2023-03-06 09:37:58 +08:00
issue Webhooks: for issue close/reopen action, add commit ID that caused it (#22583) 2023-01-24 23:47:53 -05:00
lfs Check IsActionsToken for LFS authentication (#23841) 2023-04-02 22:43:11 +08:00
mailer Preserve file size when creating attachments (#23406) 2023-03-12 03:48:07 -04:00
markup Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
migrations Introduce path Clean/Join helper functions (#23495) 2023-03-21 16:02:49 -04:00
mirror Fill head commit to in payload when notifying push commits for mirroring (#23215) 2023-03-03 23:45:53 -05:00
org Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
packages Introduce path Clean/Join helper functions (#23495) 2023-03-21 16:02:49 -04:00
pull [Patch] Fix closed PR also triggers Webhooks and actions (#23782) 2023-03-30 16:26:02 +08:00
release Delete deleted release attachments immediately from storage (#23913) 2023-04-06 18:01:36 -04:00
repository Fix tags view (#23243) 2023-03-27 21:41:33 +08:00
task Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
user add user rename endpoint to admin api (#22789) 2023-03-14 03:45:21 -04:00
webhook Fix incorrect HookEventType of pull request review comments (#23650) 2023-03-24 13:13:04 +08:00
wiki Improve utils of slices (#22379) 2023-01-11 13:31:16 +08:00