Skip to content

feat(gh-actions/gh-perms): Improve logs#105

Open
adombeck wants to merge 2 commits intomainfrom
improve-gh-perms-logs
Open

feat(gh-actions/gh-perms): Improve logs#105
adombeck wants to merge 2 commits intomainfrom
improve-gh-perms-logs

Conversation

@adombeck
Copy link
Contributor

Improve step names and group log lines.

Be more explicit about what is tested to avoid confusion when reading
the logs.
@adombeck adombeck marked this pull request as ready for review February 18, 2026 19:41
@adombeck adombeck requested a review from didrocks as a code owner February 18, 2026 19:41
Copy link
Contributor

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

A couple of nitpicks! Otherwise, good :) Thanks!

ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
token: ${{ inputs.token }}
- name: Check push permissions
- name: Check token has no contents:write permission
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite specific and explain what the step does rather than the intent, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My issue with the old name is that it doesn't make it clear what the check expects the permissions to be. When I read "Check push permissions" in the logs, I assumed that it would check that the token has push permissions. I had to look at the implementation to understand that it checks the opposite, that the token has no push permissions.

Copy link
Contributor Author

@adombeck adombeck Feb 19, 2026

Choose a reason for hiding this comment

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

We could change it to "Check no push permissions". On the other hand, contents:write gives more permissions than just pushing, so that description wouldn't be entirely accurate either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

# Push just works because we checkout with `persist-credentials: true` (the default
# behaviour).
if git push --set-upstream origin "${NEW_BRANCH}"; then
echo "::endgroup::" # Close the group first so that the error message is visible.
Copy link
Contributor

Choose a reason for hiding this comment

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

You can maybe git push in its own line before the if, save the results, then endgroup and proceed with the ifThat way, you won’t need the else, or am I missing anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also considered that but I found it more convoluted than the else. I don't have a strong opinion though, so I'll change the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

# Check token has no pull-requests:write permission
echo "::group::Check token has no contents:write permission"
if gh pr comment -b "You should restrict the github token permissions of the '${{ github.job }}' job (ideally to none - 'permissions: {}')" ${{ github.event.pull_request.number }}; then
echo "::endgroup::" # Close the group first so that the error message is visible.
Copy link
Contributor

Choose a reason for hiding this comment

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

See previous remark here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@adombeck adombeck force-pushed the improve-gh-perms-logs branch from dbdbfde to db9c9b1 Compare February 19, 2026 18:27
@adombeck adombeck requested a review from didrocks February 19, 2026 18:27
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

Comments