5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-18 01:36:26 +00:00

feat: controlador para gestionar los webhooks #13903
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
jazzari 2023-07-26 14:44:11 -03:00
parent ca67665107
commit b7e93cd8c8
5 changed files with 27 additions and 2 deletions

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
module Api
module V1
# Recibe webhooks y lanza jobs
class WebhooksController < BaseController
def pull
# encontrar el sitio
site = Site.find_by_name(params[:site_id])
usuarie = GitAuthor.new email: "webhook@#{Site.domain}", name: 'Webhook'
message = I18n.t('webhooks.pull.message')
GitPullJob.perform_later(site, usuarie, message)
end
end
end
end

View file

@ -56,7 +56,7 @@ class Site
# Incorpora los cambios en el repositorio actual
#
# @return [Rugged::Commit]
def merge(usuarie)
def merge(usuarie, message)
merge = rugged.merge_commits(head_commit, remote_head_commit)
# No hacemos nada si hay conflictos, pero notificarnos
@ -71,7 +71,7 @@ class Site
.create(rugged, update_ref: 'HEAD',
parents: [head_commit, remote_head_commit],
tree: merge.write_tree(rugged),
message: I18n.t('sites.fetch.merge.message'),
message: message,
author: author(usuarie), committer: committer)
# Forzamos el checkout para mover el HEAD al último commit y

View file

@ -466,6 +466,9 @@ en:
success: 'Site upgrade has been completed. Your next build will run this upgrade :)'
error: "There was an error when trying to upgrade your site. This could be due to conflicts that couldn't be solved automatically. A report of the issue has already been sent to our admins. Sorry for the inconvenience! :("
message: 'Skeleton upgrade'
webhooks_controller:
pull:
message: 'Webhooks upgrade'
footer:
powered_by: 'is developed by'
i18n:

View file

@ -474,6 +474,9 @@ es:
success: 'Ya se incorporaron los cambios en el sitio, se aplicarán en la próxima compilación que hagas :)'
error: 'Hubo un error al incorporar los cambios en el sitio. Esto puede deberse a conflictos entre cambios que no se pueden resolver automáticamente. Hemos enviado un reporte del problema a les administradores de Sutty para que estén al tanto de la situación. ¡Lo sentimos! :('
message: 'Actualización del esqueleto'
webhooks_controller:
pull:
message: 'Actualización desde Webhooks'
footer:
powered_by: 'es desarrollada por'
i18n:

View file

@ -17,6 +17,8 @@ Rails.application.routes.draw do
get :'contact/cookie', to: 'invitades#contact_cookie'
post :'contact/:form', to: 'contact#receive', as: :contact
post :'webhooks/pull', to: 'webhooks#pull'
end
end
end