Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2026-02-03 02:14:39 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2026-02-03 02:19:44 +0300
commitf87c68ea682de3b0545b206557a17affcdf2be3a (patch)
treedb36be81c24ceda71267bb48020f00049b8b0524
parent687e8cf1ba224c20b8b312c41fd00f891e5f26e4 (diff)
Add workflow to clean old GitHub Actions caches
Adds a scheduled GitHub Actions workflow (.github/workflows/cleanup_caches.yml) that runs weekly (and via workflow_dispatch) to delete Actions caches not accessed in the last 3 days. The job uses the gh CLI with the repository token and actions: write permission to list caches, filter by last_accessed_at against a 3-day cutoff, and delete matching cache IDs.
-rw-r--r--.github/workflows/cleanup_caches.yml31
-rw-r--r--sub/subController.go18
-rw-r--r--web/service/tgbot.go6
3 files changed, 43 insertions, 12 deletions
diff --git a/.github/workflows/cleanup_caches.yml b/.github/workflows/cleanup_caches.yml
new file mode 100644
index 00000000..dcf50fce
--- /dev/null
+++ b/.github/workflows/cleanup_caches.yml
@@ -0,0 +1,31 @@
+name: Cleanup Caches
+on:
+ schedule:
+ - cron: '0 3 * * 0' # every Sunday
+ workflow_dispatch:
+
+jobs:
+ cleanup:
+ runs-on: ubuntu-latest
+ permissions:
+ actions: write
+ steps:
+ - name: Delete caches older than 3 days
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ CUTOFF_DATE=$(date -d "3 days ago" -Ins --utc | sed 's/+0000/Z/')
+ echo "Deleting caches older than: $CUTOFF_DATE"
+
+ CACHE_IDS=$(gh api --paginate repos/${{ github.repository }}/actions/caches \
+ --jq ".actions_caches[] | select(.last_accessed_at < \"$CUTOFF_DATE\") | .id" 2>/dev/null)
+
+ if [ -z "$CACHE_IDS" ]; then
+ echo "No old caches found to delete."
+ else
+ echo "$CACHE_IDS" | while read CACHE_ID; do
+ echo "Deleting cache: $CACHE_ID"
+ gh api -X DELETE repos/${{ github.repository }}/actions/caches/$CACHE_ID
+ done
+ echo "Old caches deleted successfully."
+ fi \ No newline at end of file
diff --git a/sub/subController.go b/sub/subController.go
index 7653a4e1..53b5580b 100644
--- a/sub/subController.go
+++ b/sub/subController.go
@@ -3,8 +3,8 @@ package sub
import (
"encoding/base64"
"fmt"
- "strings"
"strconv"
+ "strings"
"github.com/mhsanaei/3x-ui/v2/config"
@@ -64,8 +64,8 @@ func NewSUBController(
subEncrypt: encrypt,
updateInterval: update,
- subService: sub,
- subJsonService: NewSubJsonService(jsonFragment, jsonNoise, jsonMux, jsonRules, sub),
+ subService: sub,
+ subJsonService: NewSubJsonService(jsonFragment, jsonNoise, jsonMux, jsonRules, sub),
}
a.initRouter(g)
return a
@@ -170,13 +170,13 @@ func (a *SUBController) subJsons(c *gin.Context) {
// ApplyCommonHeaders sets common HTTP headers for subscription responses including user info, update interval, and profile title.
func (a *SUBController) ApplyCommonHeaders(
- c *gin.Context,
- header,
- updateInterval,
- profileTitle string,
+ c *gin.Context,
+ header,
+ updateInterval,
+ profileTitle string,
profileSupportUrl string,
- profileUrl string,
- profileAnnounce string,
+ profileUrl string,
+ profileAnnounce string,
profileEnableRouting bool,
profileRoutingRules string,
) {
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index 96299050..cb84142c 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -2322,9 +2322,9 @@ func (t *Tgbot) buildSubscriptionURLs(email string) (string, string, error) {
// If pre-configured URIs are available, use them directly
if subURI != "" {
if !strings.HasSuffix(subURI, "/") {
- subURI = subURI + "/"
+ subURI = subURI + "/"
}
- subURL = fmt.Sprintf("%s%s", subURI, client.SubID)
+ subURL = fmt.Sprintf("%s%s", subURI, client.SubID)
} else {
subURL = fmt.Sprintf("%s://%s%s%s", scheme, host, subPath, client.SubID)
}
@@ -2333,7 +2333,7 @@ func (t *Tgbot) buildSubscriptionURLs(email string) (string, string, error) {
if !strings.HasSuffix(subJsonURI, "/") {
subJsonURI = subJsonURI + "/"
}
- subJsonURL = fmt.Sprintf("%s%s", subJsonURI, client.SubID)
+ subJsonURL = fmt.Sprintf("%s%s", subJsonURI, client.SubID)
} else {
subJsonURL = fmt.Sprintf("%s://%s%s%s", scheme, host, subJsonPath, client.SubID)