Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix(ci): run required checks for fork pull requests

Mike Caof544964f9777
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index aba2370f7..04ccd7792 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,6 +1,9 @@
name: Node.js CI
-on: [push]
+on: [push, pull_request]
+
+permissions:
+ contents: read
env:
DATABASE_URL: "postgresql://user:pass@localhost:5432/dummy"
@@ -13,6 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- uses: pnpm/action-setup@v4
with:
version: 12.3.4
diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml
index 6cd6386f5..fc506ea4b 100644
--- a/.github/workflows/gitleaks.yml
+++ b/.github/workflows/gitleaks.yml
@@ -17,11 +17,37 @@ jobs:
- uses: actions/checkout@v6
with:
fetch-depth: 0
+ persist-credentials: false
+
+ # The open-source CLI does not need a license secret on fork PRs.
+ - name: Install Gitleaks
+ env:
+ GITLEAKS_VERSION: 8.30.1
+ GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
+ run: |
+ install_dir="$RUNNER_TEMP/gitleaks"
+ mkdir -p "$install_dir"
+ cd "$install_dir"
+ curl --fail --silent --show-error --location --retry 3 \
+ "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
+ --output gitleaks.tar.gz
+ echo "$GITLEAKS_SHA256 gitleaks.tar.gz" | sha256sum --check
+ tar -xzf gitleaks.tar.gz gitleaks
+ echo "$install_dir" >> "$GITHUB_PATH"
- name: Run Gitleaks
- uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- # Required for organization-owned repositories.
- GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
- GITLEAKS_ENABLE_COMMENTS: "false"
+ BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
+ DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
+ run: |
+ # A new branch has no previous SHA. Compare it with the default branch.
+ if [[ "$BASE_SHA" == "0000000000000000000000000000000000000000" ]]; then
+ BASE_SHA=$(git merge-base "origin/$DEFAULT_BRANCH" "$HEAD_SHA")
+ fi
+ # Manual runs have no base SHA and scan the complete history.
+ if [[ -n "$BASE_SHA" && "$BASE_SHA" != "0000000000000000000000000000000000000000" ]]; then
+ gitleaks git --redact --log-opts="$BASE_SHA..$HEAD_SHA"
+ else
+ gitleaks git --redact --log-opts="$HEAD_SHA"
+ fi