Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDP-231603: Fix updating dependabot licenses #1409

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
uses: ./.github/workflows/test-unit.yml

check-licenses:
# Dependabot changes do not update licenses, so will never pass this check
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
uses: ./.github/workflows/check-licenses.yml

cloud-tests-filter:
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/update-licenses.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Update dependabot PR Licenses
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to patch"
required: true
push:
branches:
- dependabot/go_modules/**
Expand All @@ -12,22 +16,31 @@ jobs:
run:
name: Recompute licenses & update PR
runs-on: ubuntu-latest
env:
BRANCH: ${{ inputs.branch || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false

- name: recompute licenses
- name: Recompute licenses
run: make recompute-licenses

- uses: stefanzweifel/git-auto-commit-action@v4.1.1
with:
commit_message: |
Updated dependency licenses

dependabot skip
branch: ${{ github.head_ref }}
- name: Commit as needed
run: |
if [[ $(git diff --stat) != '' ]]; then
echo 'Committing changes'
git config user.email "akobot@ako-team-fake.mongodb.com"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this parameter mandatory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems git complains otherwise. Also it is best we know it was the bot that did the PR.

git config user.name "AKOBot"
git add .
git commit -m "Fix licenses after dependabot changes" -m "[dependabot skip]"
git push
else
echo 'Clean nothing to do'
fi
Loading