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

Affected command does not work on tags #211

Open
HashDot opened this issue Feb 2, 2022 · 2 comments
Open

Affected command does not work on tags #211

HashDot opened this issue Feb 2, 2022 · 2 comments
Labels
flag:help wanted 💪 Extra attention is needed

Comments

@HashDot
Copy link

HashDot commented Feb 2, 2022

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'
@dkhunt27
Copy link

dkhunt27 commented Feb 4, 2022

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

@jeremylvln
Copy link
Member

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 jeremylvln added the flag:help wanted 💪 Extra attention is needed label Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag:help wanted 💪 Extra attention is needed
Development

No branches or pull requests

3 participants