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

Add GitHub actions to recipes #1317

Merged
merged 17 commits into from Oct 23, 2019
Merged

Conversation

alissonperez
Copy link
Contributor

related #974

Just add a simple GitHub Actions recipe.

@gr2m
Copy link
Member

gr2m commented Oct 14, 2019

Hey I appreciate you squashing your commits to allow for rebase and merge, but while we still discuss it would actually be helpful to add commits so I can see your changes since my last review.

@alissonperez
Copy link
Contributor Author

@gr2m Changed. Could you review again, please?

What do you think about that section about repository_dispatch usage?

Tks!

@gr2m
Copy link
Member

gr2m commented Oct 14, 2019

I would really appreciate if you would write a description without mentioning GH_TOKEN and the git plugin at first, and then add a section about using the git plugin with GitHub actions and why you need to create a separate token, and how to do that. Could you do that?

What do you think about that section about repository_dispatch usage?

I like it. You could add a separate section and call it something like Trigger semantic-release on demand. You could add even another section called Trigger semantic-release on a schedule, but we can add that later

@alissonperez
Copy link
Contributor Author

@gr2m yeah, indeed. I made your suggestions, please, take a look when possible.
Tks!

Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

Looks good, just a few more comments. Thanks for bearing with me :)

docs/recipes/github-actions.md Outdated Show resolved Hide resolved
docs/recipes/github-actions.md Outdated Show resolved Hide resolved
@alissonperez
Copy link
Contributor Author

alissonperez commented Oct 14, 2019

No problem @gr2m ! Thank you for your review.. If you see any other change, please LMK..

It was adding nothing to this docs.
Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

Just one comment, otherwise it's good to go :) I'm sure other folks will have suggestions, we can iterate over time as people suggest further improvements

docs/recipes/github-actions.md Outdated Show resolved Hide resolved
Copy link
Contributor

@merlinnot merlinnot left a comment

Choose a reason for hiding this comment

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

Overall, it might be worth noting a caveat that often makes developer pull hair out of their head, that is: GitHub Actions can't trigger GitHub Actions.

To understand better why that's so painful, imagine the following scenario: there's a merge bot of any kind, that merges PRs with minimal number of approvals, generate docs, does whatever you can automate. Once this PR is merged, releases will not be triggered. Below you can find a link to an Action that merges dependency updates in a repo that uses Semantic Release. No dependency updates are released (see history).

https://github.com/ridedott/dependabot-auto-merge-action

docs/recipes/github-actions.md Outdated Show resolved Hide resolved
docs/recipes/github-actions.md Outdated Show resolved Hide resolved
docs/recipes/github-actions.md Outdated Show resolved Hide resolved
@gr2m
Copy link
Member

gr2m commented Oct 15, 2019

Overall, it might be worth noting a caveat that often makes developer pull hair out of their head, that is: GitHub Actions can't trigger GitHub Actions.

To understand better why that's so painful, imagine the following scenario: there's a merge bot of any kind, that merges PRs with minimal number of approvals, generate docs, does whatever you can automate. Once this PR is merged, releases will not be triggered. Below you can find a link to an Action that merges dependency updates in a repo that uses Semantic Release. No dependency updates are released (see history).

That is a very good point, I've lost some hair over this myself although I know about. We should add a warning

Co-Authored-By: Natan Sągol <m@merlinnot.com>
@alissonperez
Copy link
Contributor Author

@gr2m and @merlinnot , I made your suggestions..

About GitHub Actions can't trigger GitHub Actions, I didn't understand in which flow where it's not possible to happens, because I have a flow here, in a private repo, that is triggered by a http request (using repository_dispatch), this flow calls semantic release that makes a commit in master branch and generate a new release on it. Both flows (push and tagging) are triggered by GitHub. Would it be the same flow that you described? I saw your actions repository and it's really strange that merges don't triggered other actions. Is there some documentation about it?

@merlinnot
Copy link
Contributor


## Pushing `package.json` changes to `master` branch

If you want to keep your `package.json` updated in your code versioning with your released version you could use [`@semantic-release/git`](https://github.com/semantic-release/git) plugin. To use it you'll need to generate a [`GITHUB_TOKEN`](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) with [permission to push changes to `master` branch](https://help.github.com/en/articles/enabling-branch-restrictions).
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still improve this message. It suggest that users have to create this token manually in this case, but the default one already has these permissions. Do you think we can rephrase it somehow, so it's more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum, good point.. I'll think about it..

Copy link
Member

Choose a reason for hiding this comment

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

The problem with the provided GITHUB_TOKEN is that it cannot push to master if you have branch protection enabled. For that you need to create a personal access token.

You can rephrase it and say

To use it you'll need to generate a personal access token with permission to push changes to master branch. Store the personal access token as a secret, then set the GITHUB_TOKEN environment variable from it (instead of from the provided GITHUB_TOKEN secret)

        env:
          GITHUB_TOKEN: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @gr2m , I changed with your changes. Please, take a look what do you think guys. @merlinnot

@alissonperez
Copy link
Contributor Author

alissonperez commented Oct 16, 2019

This might give you some more information: https://github.community/t5/GitHub-Actions/Allow-triggering-actions-by-other-actions/td-p/34793

hum, makes sense to work for me, I'm using a specific GH_TOKEN for it, if I understood well how to trigger workflows from other workflows.

Do you think, @merlinnot, that we could add some reference or a kind of "warn" about this?

@gr2m gr2m mentioned this pull request Oct 19, 2019
@rarkins
Copy link

rarkins commented Oct 19, 2019

I think it’s becoming very common to have master branch protection enabled. What functionality exactly requires “pushing to master”?

@alissonperez
Copy link
Contributor Author

alissonperez commented Oct 20, 2019

@rarkins Yes, it's very common. I faced this problem when I needed to push my package.json changes (with new version) to master branch using https://github.com/semantic-release/git . What I did is to enable only the user from GH_TOKEN to push changes to master.

Alisson R. Perez and others added 2 commits October 19, 2019 23:46
@merlinnot
Copy link
Contributor

@alissonperez I opened a PR which should hopefully shed some light on what's broken with GITHUB_TOKEN: alissonperez#1. Could you take a look and provide me with some feedback?

Copy link
Contributor

@merlinnot merlinnot left a comment

Choose a reason for hiding this comment

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

I think it's a very good start! Let's see what issues people start to open and improve the guide based on this feedback?

@alissonperez
Copy link
Contributor Author

Yes, awesome!! Indeed! thanks @merlinnot !

Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

Let's ship it 👏

@gr2m gr2m merged commit f645547 into semantic-release:master Oct 23, 2019
JoA-MoS added a commit to semantic-release-plus/semantic-release that referenced this pull request Oct 25, 2019
@semantic-release-bot
Copy link
Collaborator

🎉 This PR is included in version 15.13.28 🎉

The release is available on:

Your semantic-release bot 📦🚀

@semantic-release-bot
Copy link
Collaborator

🎉 This PR is included in version 16.0.0-beta.27 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

None yet

5 participants