Skip to content

Switch to use the reusable DCO welcome workflow#98

Merged
qobilidop merged 1 commit intomainfrom
qobilidop-dco-reuse
Mar 3, 2026
Merged

Switch to use the reusable DCO welcome workflow#98
qobilidop merged 1 commit intomainfrom
qobilidop-dco-reuse

Conversation

@qobilidop
Copy link
Member

Context: p4lang/.github#4

@qobilidop qobilidop requested a review from Dscano March 2, 2026 02:47
`git commit --amend --signoff` or `git rebase -i HEAD~N --signoff` (where N is the number of commits)
The Developer Community DCO guide also provides helpful tips on fixing DCO inconveniences. Setting a commit hook in the git repository will automate adding the DCO signoff.
See https://github.com/p4lang/governance/wiki/P4-DCO-Guidelines for information.
uses: p4lang/.github/.github/workflows/dco-welcome-reusable.yml@main

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 20 days ago

In general, to fix this issue you should add an explicit permissions block either at the workflow root (applies to all jobs) or under the specific job that needs it, granting only the minimal permissions required (often contents: read as a baseline). This documents the intended permissions and prevents the workflow from inheriting potentially broader defaults from the repository or organization.

For this specific workflow in .github/workflows/dco-welcome.yml, the job dco-help delegates to a reusable workflow. Since we do not see any need for write access in this file, the safest minimal default is to set permissions: contents: read at the workflow root, directly under name: (or before jobs:). This will give the reusable workflow read access to repository contents but prevent it from having broad write privileges via the GITHUB_TOKEN, unless the reusable workflow further narrows or overrides permissions on its side. No additional imports or methods are required, as this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/dco-welcome.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/dco-welcome.yml b/.github/workflows/dco-welcome.yml
--- a/.github/workflows/dco-welcome.yml
+++ b/.github/workflows/dco-welcome.yml
@@ -1,4 +1,6 @@
 name: DCO Assistant for First-Time Contributors
+permissions:
+  contents: read
 
 on:
   check_run:
EOF
@@ -1,4 +1,6 @@
name: DCO Assistant for First-Time Contributors
permissions:
contents: read

on:
check_run:
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Chatted with Copilot:

At the caller site that uses this reusable workflow, do I need to repeat this permissions config again?

Let me check how this reusable workflow is being called to give you a more accurate answer.Let me search more broadly for usages of this reusable workflow:Let me check the GitHub documentation on this:Based on the GitHub documentation on reusable workflows:

No, you do NOT need to repeat the permissions configuration in the caller workflow if the reusable workflow already defines them. However, there's an important caveat:

Key Points:

  1. Optional at Caller Level: According to the documentation:

    "If jobs.<job_id>.permissions is not specified in the calling job, the called workflow will have the default permissions for the GITHUB_TOKEN."

  2. You CAN specify permissions at the caller level: The caller workflow can optionally define permissions in the job that calls the reusable workflow:

    jobs:
      call-workflow-passing-data:
        permissions:
          contents: read
          pull-requests: write
        uses: octo-org/example-repo/.github/workflows/workflow-B.yml@main
  3. Important Security Rule: The GITHUB_TOKEN permissions passed from the caller workflow can only be downgraded (not elevated) by the called workflow. This means the reusable workflow's permissions act as a safety check—they cannot exceed what the caller grants.

Recommendation:

Since your dco-welcome-reusable.yml already declares the permissions it needs, you don't need to repeat them in the caller. The reusable workflow will use those declared permissions. However, if the caller workflow has stricter requirements, specifying permissions at the caller level provides an additional security layer by further restricting what the called workflow can access.

Signed-off-by: Bili Dong <qobilidop@gmail.com>
@qobilidop qobilidop merged commit 2c22695 into main Mar 3, 2026
3 checks passed
@qobilidop qobilidop deleted the qobilidop-dco-reuse branch March 3, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants