Skip to content

Commit 2ce2872

Browse files
authored
fix: inline update-3rdparty-licenses.sh script into GH Workflow (#7058)
1 parent a408e50 commit 2ce2872

File tree

2 files changed

+43
-47
lines changed

2 files changed

+43
-47
lines changed

.github/scripts/update-3rdparty-licenses.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/update-3rdparty-licenses.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,46 @@ jobs:
8383
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
8484
PR_USER_TYPE: ${{ github.event.pull_request.user.type }}
8585
GITHUB_EVENT_NAME: ${{ github.event_name }}
86-
run: ./.github/scripts/update-3rdparty-licenses.sh
86+
GITHUB_HEAD_REF: ${{ github.head_ref }}
87+
run: |
88+
set -e
89+
90+
if git diff --ignore-space-at-eol --exit-code LICENSE-3rdparty.csv; then
91+
echo "✅ LICENSE-3rdparty.csv is already up to date"
92+
else
93+
echo "📝 LICENSE-3rdparty.csv was modified by license attribution command"
94+
95+
if [[ "$PR_USER_TYPE" == "Bot" ]] && [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
96+
echo "🤖 Bot-created PR detected. Auto-committing LICENSE-3rdparty.csv changes..."
97+
98+
git config --local user.email "action@github.com"
99+
git config --local user.name "GitHub Action"
100+
101+
git add LICENSE-3rdparty.csv
102+
git commit -m "Update LICENSE-3rdparty.csv"
103+
104+
git push origin HEAD:${GITHUB_HEAD_REF}
105+
106+
echo "✅ Successfully committed and pushed LICENSE-3rdparty.csv updates"
107+
else
108+
echo "❌ The LICENSE-3rdparty.csv file needs to be updated!"
109+
echo ""
110+
echo "The license attribution command has modified LICENSE-3rdparty.csv."
111+
echo ""
112+
echo "To fix this issue:"
113+
echo "1. Set up dd-license-attribution locally by following the installation instructions in:"
114+
echo " https://github.com/DataDog/dd-license-attribution"
115+
echo "2. Run the license CSV generation command locally:"
116+
echo " dd-license-attribution generate-sbom-csv \\"
117+
echo " --no-scancode-strategy \\"
118+
echo " --no-github-sbom-strategy \\"
119+
echo " https://github.com/datadog/dd-trace-js > LICENSE-3rdparty.csv"
120+
echo "3. Append vendored dependencies:"
121+
echo " cat .github/vendored-dependencies.csv >> LICENSE-3rdparty.csv"
122+
echo "4. Commit the updated LICENSE-3rdparty.csv file"
123+
echo "5. Push your changes"
124+
echo ""
125+
echo "This helps keep the 3rd-party license information accurate."
126+
exit 1
127+
fi
128+
fi

0 commit comments

Comments
 (0)