Skip to content

Update version comments for SHA-pinned GitHub Actions#1

Closed
jproberts wants to merge 1 commit intomainfrom
github-actions-update-semver-comments
Closed

Update version comments for SHA-pinned GitHub Actions#1
jproberts wants to merge 1 commit intomainfrom
github-actions-update-semver-comments

Conversation

@jproberts
Copy link
Copy Markdown
Owner

GitHub advocates pinning third-party GitHub Actions to a full length commit SHA. In practice, it's common for actions pinned by commit SHA to include a comment which includes the version associated with the commit. For example:

- uses: actions/checkout@01aecc # v2.1.0

This change updates the GitHub Actions manager to bump versions in comments that follow SHA-pinned actions, so the comment stays up-to-date with the SHA being updated.

The file_updater now searches the comment string for all references to the previous version and replaces them with the new version. To avoid changing unrelated comments, the comment updater only updates dependencies that pin SHA refs.

@jproberts jproberts force-pushed the github-actions-update-semver-comments branch 2 times, most recently from 3c9fb06 to 1c6c9da Compare October 21, 2022 12:10
Copy link
Copy Markdown

@hmcginnis hmcginnis left a comment

Choose a reason for hiding this comment

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

These are mostly style suggestions. But the next weirds me out. The if style might satisfy what you expect

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you could use updated_content.gsub! instead of updated_content = updated_content.gsub. The ! mutates the original updated_content

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Something like this might also work

s.gsub!(old_declaration, new_declaration)
if (comment = Regexp.last_match(:comment))
  if (updated_comment = updated_version_comment(comment, new_req))
    s.gsub!(comment, updated_comment)
  end
end

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I got this suggestion working and I like it much better. Thanks!

@jproberts jproberts force-pushed the github-actions-update-semver-comments branch 2 times, most recently from 56737a2 to 5b57517 Compare October 22, 2022 12:40
GitHub encourages pinning third-party GitHub Actions to a full
length commit SHA. It's common for actions pinned by commit SHA
to include a comment specifying the version associated with the
commit. For example:

    - uses: actions/checkout@01aecc # v2.1.0

This change updates the GitHub Actions manager to bump versions
in comments that follow SHA-pinned actions, so the comment stays
up-to-date with the SHA being updated.

The file_updater now searches the comment string for all references
to the previous version and replaces them with the new version. To
avoid changing unrelated comments, the comment updater only
updates dependencies that pin SHA refs.
@jproberts jproberts force-pushed the github-actions-update-semver-comments branch from 5b57517 to 96b107c Compare October 22, 2022 12:50
@jproberts
Copy link
Copy Markdown
Owner Author

Moved to dependabot#5951 🎉

@jproberts jproberts closed this Oct 22, 2022
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