-
Notifications
You must be signed in to change notification settings - Fork 728
Description
Affected Packages
@changesets/cli
Problem
My original plan was to create a tag/version based deployment for my monorepo, where changesets would handle the versioning and tagging. I set up github actions workflows that are triggered on.push.tags.
At first I was using the workflow:
name: Version
permissions:
pull-requests: write
contents: write
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- name: Create Release Pull Request
uses: changesets/action@v1
with:
createGithubReleases: false
publish: pnpm changeset tag
env:
GITHUB_TOKEN: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
HUSKY: 0
I had some more complex workflows for deploying apps, but for demonstration say there is one workflow for creating tag for api. Running changeset, then changeset version then changeset tag should create tag api@0.0.1, which should trigger:
name: Test tag
permissions:
pull-requests: write
contents: write
on:
push:
tags:
- api@[0-9]+.[0-9]+.[0-9]+
jobs:
didirun:
name: Did it run
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checker
run: echo YES!
Where everything works fine, I create the changeset, the PR is created for the version bump, and upon merging to main, it creates and pushes the tags.
The problem is it doesn't trigger the "Test tag" workflow.
I thought that based on this discussion the reason is because the tags are created by a bot, and I replaced the action's GITHUB_TOKEN with a PAT stored in secrets.CHANGESET_GITHUB_TOKEN. It didn't help.
Further debugging, I ran the whole flow manually locally (on main).
pnpm changeset
pnpm version
git commit -m "Version bump"
pnpm changeset tag
> 🦋 New tag: api@0.0.3
> 🦋 New tag: admin@0.0.3
> 🦋 New tag: storefront@0.0.3
> 🦋 New tag: service@0.0.3
git push
git push --tags
> * [new tag] api@0.0.3 -> api@0.0.3
> * [new tag] admin@0.0.3 -> admin@0.0.3
> * [new tag] storefront@0.0.3 -> storefront@0.0.3
> * [new tag] service@0.0.3 -> service@0.0.3
No workflow run.
Then I created a tag manually with
git tag api@0.0.999
and pushed it, then it triggered the workflow.
Then created an even more simplified version, deleted every package, every app except api, and the workflow has been triggered even with changeset.
I was quite frustrated at this point, but curiosity drove me forward to find out yet another of the many undocumented annoying behaviour of github actions in this discussion.
Apparently, if you push more than 3 tags at once, github actions will just ignore all of them, not running any workflows triggered by on.push.tags.
Proposed solution
The ideal solution would be to somehow demolish the hype around github actions so they will finally build something without weird behaviour that people are complaining about for years receiving hundreds of likes, so they finally wake up and at least document these behaviours so people don't have to research hours and days to manually figure out what's causing unexpected things. But I guess none of us can do anything about this, gh actions is the industry standard. Sorry for the rant.
Pushing tags one-by-one could work as proposed solution of this discussion.
Also, tags pushed by changesets/action@v1 don't trigger on.push.tags even when only one tag is being pushed, and even when a custom PAT is passed to env.GITHUB_TOKEN most likely because of this discussion. This one is not a priority though, I'll just ditch the action, and do the version bump and tagging manually, but not being able to trigger custom workflows for each app independently based on tag name if there are more than 3 is a blocker.