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

Fix issue with packager installation if path is not repository root #31

Merged
merged 2 commits into from
Jan 3, 2024

Conversation

samrith-s
Copy link
Contributor

If you try to use this action with a path option specified other than ., the action fails with the following message:

Run withastro/action@v1
  with:
    path: docs
    package-manager: yarn
    node-version: 18
Run len=`echo $INPUT_PM | wc -c`
  len=`echo $INPUT_PM | wc -c`
  if [ $len -gt 1 ]; then
    PACKAGE_MANAGER=$(echo "$INPUT_PM" | grep -o '^[^@]*')
    VERSION=$(echo "$INPUT_PM" | grep -o '@.*' | sed 's/^@//')
    # Set default VERSION if not provided
    if [ -z "$VERSION" ]; then
        VERSION="latest"
    fi
    echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" >> $GITHUB_ENV
  elif [ $(find "." -name "pnpm-lock.yaml") ]; then
      echo "PACKAGE_MANAGER=pnpm" >> $GITHUB_ENV
      echo "LOCKFILE=pnpm-lock.yaml" >> $GITHUB_ENV
  elif [ $(find "." -name "yarn.lock") ]; then 
      echo "PACKAGE_MANAGER=yarn" >> $GITHUB_ENV
      echo "LOCKFILE=yarn.lock" >> $GITHUB_ENV
  elif [ $(find "." -name "package-lock.json") ]; then 
      VERSION="latest"
      echo "PACKAGE_MANAGER=npm" >> $GITHUB_ENV
      echo "LOCKFILE=package-lock.json" >> $GITHUB_ENV
  elif [ $(find "." -name "bun.lockb") ]; then 
      VERSION="latest"
      echo "PACKAGE_MANAGER=bun" >> $GITHUB_ENV
      echo "LOCKFILE=bun.lockb" >> $GITHUB_ENV
  else
      echo "No lockfile found.
  Please specify your preferred \"package-manager\" in the action configuration."
      exit 1
  fi
  echo "VERSION=$VERSION" >> $GITHUB_ENV
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    INPUT_PM: yarn
Error: Process completed with exit code 1.

This is because it tries to find a lock file in the root directory rather than in the directory specified in path. This PR aims to fix it.

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

This makes sense to me!

@samrith-s
Copy link
Contributor Author

Just have one question, are there any tests to ascertain if this works? Coz I was getting an error earlier which is what prompted me to make this PR.

@Faf4a
Copy link

Faf4a commented Dec 9, 2023

I'm also still encountering this issue.

For documentation: https://github.com/aoijs/website/actions/runs/7152884666/job/19478704479

@samrith-s
Copy link
Contributor Author

@Faf4a this has not been merged yet. Have you tried with this patch? Alternatively, I am using a completely custom deployment script which you can find here: https://github.com/samrith-s/concurrent-tasks/blob/main/.github/workflows/github-pages.yml

@Faf4a
Copy link

Faf4a commented Dec 10, 2023

@Faf4a this has not been merged yet. Have you tried with this patch? Alternatively, I am using a completely custom deployment script which you can find here: https://github.com/samrith-s/concurrent-tasks/blob/main/.github/workflows/github-pages.yml

Oh, must've overlooked that. Thanks.

@samrith-s
Copy link
Contributor Author

@natemoo-re Any update on this PR?

@ionicsolutions
Copy link

I just ran into the same issue when someone added additional NPM projects to a monorepo. Would love for this to get merged.

@Princesseuh Princesseuh merged commit 64c331d into withastro:main Jan 3, 2024
@torn4dom4n
Copy link
Contributor

@Princesseuh I got an issue after this PR was merged.

@Princesseuh
Copy link
Member

@Princesseuh I got an issue after this PR was merged.

It's not released yet, it's just merged

@torn4dom4n
Copy link
Contributor

@Princesseuh I got an issue after this PR was merged.

It's not released yet, it's just merged

I see v1.0.4 release here and the last I try to run GitHub action it shows:

Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v4' (SHA:b4ffde65f46336ab88eb53be808477a3936bae11)
Download action repository 'withastro/action@v1' (SHA:64c331d10da115fbaab6c13ceb8d64f06199a703)
Error: withastro/action/v1/action.yml (Line: 96, Col: 7): Unexpected value 'working-directory'
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. withastro/action/v1/action.yml (Line: 96, Col: 7): Unexpected value 'working-directory'
   at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load withastro/action/v1/action.yml

It's the lastest released.

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

6 participants