Unverified Commit 088295e0 authored by Meenakshi Sharma's avatar Meenakshi Sharma Committed by GitHub
Browse files

ci: Create DCO.md to help contributors (#3171)


Signed-off-by: default avatarMeenakshi Sharma <163925564+nvda-mesharma@users.noreply.github.com>
Co-authored-by: default avatarRyan McCormick <rmccormick@nvidia.com>
parent da3b1dbd
name: DCO Commenter
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
issues: write
checks: read
jobs:
dco-comment:
runs-on: ubuntu-latest
steps:
- name: Get DCO status
id: dco
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: checks } = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.payload.pull_request.head.sha,
});
const dco = checks.check_runs.find(run => run.name === "DCO");
core.setOutput("conclusion", dco ? dco.conclusion : "not_found");
- name: Comment if DCO failed (deduped)
if: steps.dco.outputs.conclusion == 'failure'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
⚠️ Your pull request failed the DCO check.
Don’t worry! Check out our [DCO Troubleshooting Guide](https://github.com/ai-dynamo/dynamo/blob/main/DCO.md) for step-by-step instructions to fix it quickly.
edit-mode: replace
...@@ -191,3 +191,6 @@ You may type this line on your own when writing your commit messages. ...@@ -191,3 +191,6 @@ You may type this line on your own when writing your commit messages.
However, if your user.name and user.email are set in your git configs, However, if your user.name and user.email are set in your git configs,
you can use `-s` or `--signoff` to add the `Signed-off-by` line to you can use `-s` or `--signoff` to add the `Signed-off-by` line to
the end of the commit message. the end of the commit message.
⚠️ **Contributor-Friendly DCO Guide:**
If your pull request fails the DCO check, don’t worry! Check out our [DCO Troubleshooting Guide](DCO.md) for step-by-step instructions to fix it quickly.
# ✅ Fixing DCO Check Failures
The **Developer Certificate of Origin (DCO)** check ensures all commits are signed off.
If your PR fails the DCO check, here’s how to fix it.
---
## 🖥️ Option 1: Fix via GitHub Web Editor
⚠️ Works only if your PR has 1 commit.
1. Go to your **Pull Request****Commits** tab.
2. Click the **⋯ menu****Edit commit message**.
3. Add this line at the end of the commit message:
```text
Signed-off-by: Your Name <your.email@example.com>
```
4. Save changes → GitHub will create a new commit with sign-off.
5. Re-run the DCO check.
## 📦 Option 2: Fix via GitHub Desktop
1. Open your branch in GitHub Desktop.
2. Go to Repository → Repository Settings → Commit Behavior.
3. Check ✅ Always sign-off commits.
4. Amend the last commit:
- Right-click the commit → Amend Commit.
- Save again with sign-off enabled.
5. Push with force (if required):
```
git push --force-with-lease
```
## 💻 Option 3: Fix via CLI (Multiple Commits)
1. Enable sign-off in your config:
```
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```
2. Re-sign commits interactively:
```
git rebase -i HEAD~N
```
Replace N with the number of commits to fix.
Mark commits as edit, then run:
```
git commit --amend --signoff
git rebase --continue
```
3. Push with:
```
git push --force-with-lease
```
## 🔀 If Your Branch Is Messy After Syncing with main
- Simplest fix: squash all commits into a single new signed commit (via Desktop or CLI).
- Alternatively, ask a maintainer to Squash and Merge with a sign-off on merge.
## ✨ Pro Tips
This ensures you’ll never fail DCO again.
- Use the -s flag when committing from CLI:
```
git commit -s -m "Your commit message"
```
- Turn on Always sign-off commits in your client (GitHub Desktop or Git CLI).
1. GitHub Desktop
Turn on Always sign-off commits in your client.
2. Git CLI
You can always sign-off commits automatically using a commit template (NOTE: This will only work if you use enter your commit message interactively with `git commit`, and will _not_ work with `git commit -m "<message>"`):
1. Create ~/.git-commit-template.txt with:
```
Signed-off-by: Your Name <your.email@example.com>
```
2. Tell Git to use it:
```
git config --global commit.template ~/.git-commit-template.txt
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment