Skip to content

Commit 064a6c8

Browse files
fix(ci): skip Datadog reporting steps on non-main branches
Forked PRs lack id-token:write permissions required by dd-sts-action, causing the "Get Datadog credentials" step to fail. Gate all DD CI reporting steps (STS credentials, test optimization, orchestrion, coverage upload) to only run on main. Tests still run on all PRs via the existing plain `go test` fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 677f3c0 commit 064a6c8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,22 @@ jobs:
4141
cache: true
4242

4343
- name: Get Datadog credentials
44+
if: github.ref == 'refs/heads/main'
4445
id: dd-sts # Needed to be able to reference this step's output later
4546
uses: DataDog/dd-sts-action@main # Pin to the main branch to get auto updates for free, or to a specific commit hash if you want stability
4647
with:
4748
policy: public-datadog-pup-sts
4849

4950
- name: Configure Datadog Test Optimization
51+
if: github.ref == 'refs/heads/main'
5052
uses: datadog/test-visibility-github-action@v2
5153
with:
5254
languages: go
5355
api_key: ${{ steps.dd-sts.outputs.api_key }}
5456
site: datadoghq.com
5557

5658
- name: Install Datadog CI tools
59+
if: github.ref == 'refs/heads/main'
5760
run: |
5861
# Install orchestrion for Go test instrumentation
5962
go install github.com/DataDog/orchestrion@latest
@@ -117,7 +120,7 @@ jobs:
117120
go tool cover -func=coverage.out | tail -1 >> coverage_report.txt
118121
119122
- name: Upload coverage to Datadog
120-
if: env.DD_API_KEY != ''
123+
if: github.ref == 'refs/heads/main'
121124
env:
122125
DATADOG_API_KEY: ${{ steps.dd-sts.outputs.api_key }}
123126
DD_SITE: datadoghq.com

0 commit comments

Comments
 (0)