This application is designed to automatically process Gitea push webhooks. When a push event is received for a repository, the application will:
- Clone the repository associated with the push event.
- Find all forks of this repository.
- For each fork:
- Clone the fork.
- Calculate the difference between the fork and the origin repository.
- Merge changes from the origin repository into the fork.
- Push the merged changes to the fork.
The application uses several Go libraries:
- Standard Go libraries like
encoding/json
,io
,log
,net/http
,os
,path/filepath
, andstrings
. - Gitea modules for structs (
code.gitea.io/gitea/modules/structs
). - Go-git libraries (
github.com/go-git/go-git/v5
and its sub-modules) for Git operations.
The application reads Gitea credentials from the following files:
/etc/assist-secret/gitea-username
for the username./etc/assist-secret/gitea-password
for the password.
Ensure these files are present and contain the necessary credentials for accessing Gitea repositories.
/onPush
: Endpoint to receive Gitea push webhooks./readiness
: A readiness endpoint that returns 200 OK, indicating the service is ready to handle requests./liveness
: A liveness endpoint that returns 200 OK, indicating the service is alive and healthy.
To run the application, simply execute:
go run main.go
This will start an HTTP server on port 9000.
This script automates the creation of a Kubernetes secret named
gitea-assist-creds
, which stores Gitea credentials. By default, it generates
a random 12-character password and sets the username to gitea_admin
.
However, you can specify custom values for both.
-
Default (random password,
gitea_admin
username):./mk_passwd.py
-
Specify a password:
./mk_passwd.py --password <your_predefined_password>
-
Specify a username:
./mk_passwd.py --username <your_predefined_username>
-
Specify both password and username:
./mk_passwd.py --password <your_predefined_password> --username <your_predefined_username>
The script checks if the gitea-assist-creds
secret exists. If not, it
creates the secret with the given or default credentials. If the secret
exists, a notification is printed, and no changes are made.