Skip to content

Conversation

@samsarkleio
Copy link
Contributor

@samsarkleio samsarkleio commented May 25, 2021

Initial workflow for pushing to rubygems.

This creates a workflow that is triggered after a release is published on github. It uses a token created specifically for github actions to be able to push a gem to rubygems.org.

Initial workflow for pushing to rubygems.
Comment on lines 4 to 7
# push:
# branches: [ master ]
# run manually for now
workflow_dispatch:
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually, could we have this linked to creating on publishing a new release?
https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release

Out of curiosity, how can we run actions manually? I've only had experience with automatically triggered ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to be run after a published release.

Before, to run it manually, we'd have to go to the "Actions" tab, select the workflow, and click "Run Manually". I wanted to have this for testing, but I think it's straightforward enough to just try a release.

Comment on lines 31 to 32
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking, but could we add the env line above the run? I find it slightly easier to read the GEM_HOST_API_KEY being set, then how it's used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines +13 to +14
permissions:
contents: read
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a required change, but I believe @npaufler set the default Actions permission to read, so I think we get read by default.

mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
Copy link
Contributor

@alecclarke alecclarke May 25, 2021

Choose a reason for hiding this comment

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

Will this log the token to the Action's artifacts (where it can be viewed by any contributor)? If so, can it be used maliciously?

Copy link
Contributor

Choose a reason for hiding this comment

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

Its a push only API token and you can't replace an existing gem version in rubygems.org. This should not end up in artifacts from what I understand. This is literally the supplied code from GitHub for implementing this action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above line puts the credentials in a file, it won't be logged/printed anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah! Thanks for the explanation! That was the piece I was missing.

Address PR comments
Update to run workflow after a release has been published.
Copy link
Contributor

@alecclarke alecclarke left a comment

Choose a reason for hiding this comment

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

Thank you for adding this in! It will make working on our public gems much easier ❤️

@samsarkleio samsarkleio merged commit 6a6df72 into master May 26, 2021
@samsarkleio samsarkleio deleted the push-rubygem-action branch May 26, 2021 13:14
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.

4 participants