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

fix(workflow): fix DCO check #3512

Merged
merged 1 commit into from
Feb 4, 2025
Merged
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
13 changes: 10 additions & 3 deletions .github/workflows/create-crd-update-pr-in-longhorn-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ jobs:
bash scripts/generate-longhorn-yaml.sh
bash scripts/helm-docs.sh

- name: Get Head Commit Name
id: get_head_commit_name
run: echo "::set-output name=commit_name::$(git log -1 --pretty=format:'%an')"

- name: Get Head Commit Email
id: get_head_commit_email
run: echo "::set-output name=commit_email::$(git log -1 --pretty=format:'%ae')"

Comment on lines +40 to +47
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

🛠️ Refactor suggestion

Deprecated set-output Usage Confirmed in Workflow

The search result confirms that the workflow file still uses the deprecated ::set-output command at the following lines:

  • Line 42: Uses ::set-output for the commit name.
  • Line 46: Uses ::set-output for the commit email.

Please update these steps to use the $GITHUB_OUTPUT mechanism as detailed in the review comment to comply with the updated GitHub Actions guidelines.

🔗 Analysis chain

Update Deprecated set-output Commands

The steps "Get Head Commit Name" (line 42) and "Get Head Commit Email" (line 46) still use the deprecated ::set-output command. To comply with the current GitHub Actions guidelines, update these commands to use the $GITHUB_OUTPUT mechanism. For example, you could replace the current implementation with:

-      run: echo "::set-output name=commit_name::$(git log -1 --pretty=format:'%an')"
+      run: |
+        if ! commit_name=$(git log -1 --pretty=format:'%an'); then
+          echo "Failed to get commit author name" >&2
+          exit 1
+        fi
+        echo "commit_name=$commit_name" >> $GITHUB_OUTPUT

and similarly for the commit email:

-      run: echo "::set-output name=commit_email::$(git log -1 --pretty=format:'%ae')"
+      run: |
+        if ! commit_email=$(git log -1 --pretty=format:'%ae'); then
+          echo "Failed to get commit author email" >&2
+          exit 1
+        fi
+        echo "commit_email=$commit_email" >> $GITHUB_OUTPUT

This change aligns with the updated GitHub Actions syntax and resolves warnings from static analysis tools.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts or web queries found


Script:

#!/bin/bash
# Verify deprecated set-output commands in the workflow file
rg --line-number "::set-output" .github/workflows/create-crd-update-pr-in-longhorn-repo.yml

Length of output: 268

🧰 Tools
🪛 actionlint (1.7.4)

42-42: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


46-46: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
Expand All @@ -46,9 +54,8 @@ jobs:
delete-branch: true
sign-commits: true
signoff: true
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
committer: Longhorn GitHub Bot <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

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

Do we know why the bot account with sign is not valid for DCO check?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea for now. Although I set the committer and author to Longhorn bot, the longhorn/longhorn PR will be created by the author of the longhorn/longhorn-manager PR rather than the Longhorn bot when triggering the workflow by pull_request_target. However, using the author of the longhorn/longhorn-manager PR might make sense.

commit-message: "chore(crd): update crds.yaml and manifests"
author: ${{ steps.get_head_commit_name.outputs.commit_name }} <${{ steps.get_head_commit_email.outputs.commit_email }}>
committer: ${{ steps.get_head_commit_name.outputs.commit_name }} <${{ steps.get_head_commit_email.outputs.commit_email }}>
title: "chore(crd): update crds.yaml and manifests (PR longhorn/longhorn-manager#${{ github.event.pull_request.number}})"
body: |
This PR updates the crds.yaml and manifests.
Expand Down
Loading