Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Trigger publish from release workflow #193

Merged
merged 3 commits into from
Oct 22, 2020

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Sep 29, 2020

For the release of 1.0.0-beta.5, I was excited to test out the automated release workflows put in place by #190. Unfortunately, things didn't work exactly as expected. Although a release was created in response to pushing a tag, the deploy workflow didn't trigger in response to that release being created. At first I thought it was an issue with the event type, but then I saw this in the GitHub Actions documentation:

Triggering new workflows using a personal access token

When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

If you would like to trigger a workflow from a workflow run, you can trigger the event using a personal access token. You'll need to create a personal access token and store it as a secret. To minimize your GitHub Actions usage costs, ensure that you don't create recursive or unintended workflow runs.

This PR passes the GH_PERSONAL_ACCESS_TOKEN as GITHUB_TOKEN for the actions/create-release action, which should allow one workflow to trigger the other.

@mattt mattt marked this pull request as draft October 6, 2020 17:57
@mattt
Copy link
Contributor Author

mattt commented Oct 6, 2020

The original publish flow also gets the bottling process totally wrong. I'd like to fix that in this PR.

Edit: Done (12dfa51).

@mattt mattt marked this pull request as ready for review October 13, 2020 17:12
Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

This is great! I didn't know that preparing brew bottle was so easy, I previously had an impression that's too hard to maintain. Now there's a great example for a workflow setup 🙂

@mattt
Copy link
Contributor Author

mattt commented Oct 14, 2020

@MaxDesiatov I know, right? Homebrew is centralized by default, and any documentation I found about the process was specific to their Brew Test Bot service. Back when it launched in 2013, virtualized macOS instances were few and far between, so I can see why that was necessary. But now in 2020 we have GitHub Actions and other infrastructure to stand that up ourselves. I'm not entirely sure when Homebrew started supporting this workflow, but I think this pattern could really start to catch on.

@mattt mattt merged commit 1641575 into master Oct 22, 2020
@mattt mattt deleted the trigger-publish-from-release-workflow branch October 22, 2020 13:41

on:
release:
types: [created, published]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what's the difference between these two? It doesn't seem to be documented in the trigger events doc.

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'm not 100% sure, but GitHub's UI copy gives us some clue. On the releases page, the button says "Draft a new release". On that page, there are two buttons, "Publish release" or "Save as draft". The former likely corresponds to a published event, and the latter may trigger a created step.

Here, we're creating a release through the github/create-release action, whose name implies a created event, but I vaguely recall triggering published instead. It's really too bad that there's no easy way to do a dry run of this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants