Skip to content

Commit 38ee95c

Browse files
authored
[skip-changelog] Try to whitelist CI for Cloudflare spam-check filters (#1796)
* Provide a way to define extra UserAgent fields via env vars * Add secret token to User Agent This will allow to possibly bypass spam-checks on the server side reducing the jobs failures due to rate limiting.
1 parent 6ac5f7a commit 38ee95c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: .github/workflows/test-go-integration-task.yml

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ jobs:
8484

8585
runs-on: ${{ matrix.operating-system }}
8686

87+
env:
88+
ARDUINO_CLI_USER_AGENT_EXTENSION: ${{ secrets.CLOUDFLARE_SPAMCHECK_BYPASS_TOKEN }}
89+
8790
steps:
8891
# By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner.
8992
- name: Disable EOL conversions

Diff for: configuration/network.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package configuration
1818
import (
1919
"fmt"
2020
"net/url"
21+
"os"
2122
"runtime"
2223

2324
"github.com/arduino/arduino-cli/cli/globals"
@@ -34,12 +35,18 @@ func UserAgent(settings *viper.Viper) string {
3435
subComponent = " " + subComponent
3536
}
3637

37-
return fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s",
38+
extendedUA := os.Getenv("ARDUINO_CLI_USER_AGENT_EXTENSION")
39+
if extendedUA != "" {
40+
extendedUA = " " + extendedUA
41+
}
42+
43+
return fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s%s",
3844
globals.VersionInfo.Application,
3945
globals.VersionInfo.VersionString,
4046
subComponent,
4147
runtime.GOARCH, runtime.GOOS, runtime.Version(),
42-
globals.VersionInfo.Commit)
48+
globals.VersionInfo.Commit,
49+
extendedUA)
4350
}
4451

4552
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)

0 commit comments

Comments
 (0)