nrwl-nx-action icon indicating copy to clipboard operation
nrwl-nx-action copied to clipboard

Affected command does not work on tags

Open HashDot opened this issue 2 years ago • 2 comments

Bug Report

Current behavior

I want to build only the affected apps when I create a new tag. The problem is that on a tag the last commit is only zeros. Is it possible that this works? My workaround is to build everything. :/

Expected behavior

Build only the affected apps.

Output

$ nx affected --target=lint --base=0000000000000000000000000000000000000000 --head=6cb6624933ed92b53c116d2271b23af57916b70a
fatal: Not a valid commit name 0000000000000000000000000000000000000000
fatal: No such ref: '0000000000000000000000000000000000000000'

HashDot avatar Feb 02 '22 15:02 HashDot

I needed something similiar.... I needed to get all changes since the last tag which isn't necesarily HEAD~1. So I just added a PR that will allow you to specify the base commit hash, which you can use when you find the last tag commit hash.... so this is how I am currently using it (just FYI, my version 'dkhunt27/[email protected]' does exist now, but I will delete that once my PR is merged to this repo)

  - name: Determine base commit hash (find last release/tag)
    run: |
      # if you need to use a specific version
      # git log --oneline --grep="chore(release): v0.1.6" -n1
      # PREVIOUS_TAG_HASH=`git log --oneline --grep="chore(release): v0.1.6" -n1 | cut -d ' ' -f1`
      git --no-pager log --oneline $(git describe --tags --abbrev=0) -n1
      PREVIOUS_TAG_HASH=`git --no-pager log --oneline $(git describe --tags --abbrev=0) -n1 | cut -d ' ' -f1`
      echo "PREVIOUS_TAG_HASH=$PREVIOUS_TAG_HASH" >> $GITHUB_ENV

  - name: Build (Nx Affected)
    uses: dkhunt27/[email protected]
    with:
      targets: build
      affected: true
      affectedBaseNonPR: ${{ env.PREVIOUS_TAG_HASH }} # need to go back to last release/tag
      nxCloud: false

dkhunt27 avatar Feb 04 '22 15:02 dkhunt27

Hi!

Sorry for this long time, I've been really busy quite recently. I've lookup at GitHub's documentation, and I'm surprised there is no GitHub Actions event when a tag is created, which could exposes the information that @dkhunt27 fetch manually. I'm not against bundling this logic into the action, but I don't think I will have the time to implement this myself. For now.

I see that a PR was already opened by @dkhunt27, I will take a look at it shortly :)

jeremylvln avatar Mar 10 '22 18:03 jeremylvln