diff --git a/.gitea/workflows/run-forgejo-release-sync.yml b/.gitea/workflows/run-forgejo-release-sync.yml new file mode 100644 index 0000000..e576836 --- /dev/null +++ b/.gitea/workflows/run-forgejo-release-sync.yml @@ -0,0 +1,54 @@ +name: Run Forgejo Release Sync + +on: + schedule: + - cron: '0 0 * * *' # daily at 00:00 UTC + push: + branches: + - master + workflow_dispatch: + +jobs: + sync: + runs-on: tsv-s1 + container: + image: hub.hamdocker.ir/docker:dind + privileged: true + + steps: + - name: Switch Alpine to MobinHost mirror + run: | + ALPINE_VERSION=$(cat /etc/alpine-release | cut -d. -f1,2) + echo "https://mirror.mobinhost.com/alpine/v${ALPINE_VERSION}/main" > /etc/apk/repositories + echo "https://mirror.mobinhost.com/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories + + - name: Install required tools + run: apk add --no-cache git + + - uses: actions/checkout@v7 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + with: + buildkitd-config-inline: | + [registry."docker.io"] + mirrors = ["https://hub.hamdocker.ir"] + + - name: Build image + uses: docker/build-push-action@v7 + with: + context: ForgejoReleaseSync + file: ForgejoReleaseSync/Dockerfile + push: false + load: true + tags: forgejo-release-sync:latest + + - name: Run sync + run: | + docker run --rm \ + -e FORGEJO_INSTANCE="${{ secrets.FORGEJO_INSTANCE }}" \ + -e FORGEJO_TOKEN="${{ secrets.FORGEJO_TOKEN }}" \ + -e SYNC_CONCURRENCY="${{ vars.SYNC_CONCURRENCY || '3' }}" \ + -e REPO_CONFIG_FILE="/config/config.toml" \ + -v "${{ github.workspace }}/config.toml:/config/config.toml:ro" \ + forgejo-release-sync:latest diff --git a/.gitignore b/.gitignore index 88743a2..3cd1259 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ obj/ riderModule.iml /_ReSharper.Caches/ -.env -config.toml +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4abfef1..721b9e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,28 @@ -FROM mcr.microsoft.com/dotnet/runtime:10.0 AS base -USER $APP_UID -WORKDIR /app - -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +FROM mcr.hamdocker.ir/dotnet/sdk:10.0.403-alpine3.24-aot AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["ForgejoReleaseSync.csproj", "./"] + +RUN echo "https://mirror.mobinhost.com/alpine/v3.24/main" > /etc/apk/repositories && \ + echo "https://mirror.mobinhost.com/alpine/v3.24/community" >> /etc/apk/repositories + +RUN apk add --no-cache clang zlib-dev + +RUN dotnet nuget remove source nuget.org && \ + dotnet nuget add source https://repo.hmirror.ir/nuget --name hmirror + RUN dotnet restore "ForgejoReleaseSync.csproj" COPY . . -WORKDIR "/src/" -RUN dotnet build "./ForgejoReleaseSync.csproj" -c $BUILD_CONFIGURATION -o /app/build -FROM build AS publish -ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "./ForgejoReleaseSync.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "ForgejoReleaseSync.csproj" \ + -r linux-musl-x64 \ + -c $BUILD_CONFIGURATION \ + -p:PublishAot=true \ + -p:StripSymbols=true \ + -p:InvariantGlobalization=true \ + -o /app -FROM base AS final +FROM mcr.hamdocker.ir/dotnet/runtime-deps:10.0.14-alpine3.24 WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "ForgejoReleaseSync.dll"] +COPY --from=build /app . +ENTRYPOINT ["/app/ForgejoReleaseSync"] \ No newline at end of file diff --git a/ForgejoReleaseSync.sln.DotSettings.user b/ForgejoReleaseSync.sln.DotSettings.user new file mode 100644 index 0000000..02bb46d --- /dev/null +++ b/ForgejoReleaseSync.sln.DotSettings.user @@ -0,0 +1,4 @@ + + ForceIncluded + ForceIncluded + ForceIncluded \ No newline at end of file diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..14c58ff --- /dev/null +++ b/config.toml @@ -0,0 +1,18 @@ +[[chisel]] +GithubUrl = "https://github.com/jpillora/chisel" +ForgejoUrl = "https://gm.monasef.ir/jpillora/chisel" +IncludeAssetsRegex = '^chisel_.*_(?:linux_(?:amd64|arm(?:64|v[5-7])?)|windows_(?:amd64|arm64)|darwin_(?:amd64|arm64))(?:\.|$)' +ExcludeAssetsRegex = '^(?:^|_)(?:openbsd|386|mips[^_.]*|ppc64le?|s390x)(?:_|\.|$)' + +#[[WhiteDNS-Wizard]] +#GithubUrl = "https://github.com/WhiteDNS/WhiteDNS-Wizard" +#ForgejoUrl = "https://gm.monasef.ir/WhiteDNS/WhiteDNS-Wizard" +#IncludeAssetsRegex = '^whitedns_.*_(?:linux-(?:amd64|arm(?:64|v[5-8])?)|macos-(?:amd64|arm64)|windows-(?:amd64|arm64))\.' +#ExcludeAssetsRegex = '(?:^|_)(?:freebsd|netbsd|openbsd|termux-android|[^_]+-(?:386|ppc\d*(?:le)?|riscv\d*|s390x|mips[^_.]*|loong64|wasm[^_.]*))(?=\.|_)' + +#[[WhiteDNS-Android]] +#GithubUrl = "https://github.com/WhiteDNS/WhiteDNS-Android" +#ForgejoUrl = "https://gm.monasef.ir/WhiteDNS/WhiteDNS-Android" +#IncludeAssetsRegex = '^WhiteDNS-.*-(?:arm64-v8a|armeabi-v7a)\.apk$' +#ExcludeAssetsRegex = '-(?:x86(?:_64)?|universal)\.apk(?:\.idsig)?$' +