question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run the action from a different directory

See original GitHub issue

Hi,

I am trying to use this Github Actions to push a VuePress website from a source branch to a master branch. The website is generated using a regular npm run build script and the build outputs to ./docs/.vuepress/dist.

./ here is the root of my repo.

I would like to only push files inside of this directory to the master, not the whole path.

The problem is that currently the action is running git add from the root folder, instead of running it from .docs/.vuepress/dist… resulting in having the full path pushed to the master branch.

As for now Github Actions working-directory can’t be used in addition with the uses command, it would be nice to have a directory option to tell the action where to run the git add command.

Here is my worflow:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      (...)
      - name: Commit changes
        uses: EndBug/add-and-commit@master
        with:
          branch: "master"
          add: "docs/.vuepress/dist --force"
          message: "Deploy docs"

Here is a workflow we could have:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      (...)
      - name: Commit changes
        uses: EndBug/add-and-commit@master
        with:
          branch: "master"
          directory: "docs/.vuepress/dist" <--- the action will run "cd [directory]" command before running
          add: ". --force"
          message: "Deploy docs"

You can have a look at the current VuePress deploy script here: https://vuepress.vuejs.org/guide/deploy.html#github-pages

Thanks for your feedback! 😉

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
xavierfoucriercommented, Oct 29, 2020

Fine, I will choose the more appropriate option. Thanks for the fast answers/support anyway!

I am closing the issue 😉

1reaction
EndBugcommented, Oct 29, 2020

The Vue docs say to navigate to that directory only because they’re creating a new repo and then pushing to a custom URL, which my action doesn’t currently support.

This are your options:

  • You can use some git commands to create a new repo and push to a custom URL, but at that point it’s just easier for you to commit directly by running a couple of commands, instead of using the action. If you wanted to use it anyway, you’d need to use the cwd option to make it run on that repo.
  • You can generate your dist, copy over the files, and then use my action to commit everything
  • You can use gh-pages (which is what I would do), to directly publish the dist folder to your branch (you can edit the name of the branch it uses)

In any of these three ways, there are no changes needed for the action.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running actions in another directory - github - Stack Overflow
I'm fairly sure this option only works for script steps, not action steps with uses .
Read more >
Run your Github Actions jobs from a specific directory
Specify for all Jobs:​​ Github actions have a working-directory option to declare on workflow. It specifies the working directory for all run ......
Read more >
Running Github Actions in a Sub Directory - TecAdmin
Running Command in Subdirectory with Github Actions. For example, your application have composer.json file under the “app” directory.
Read more >
Use working-directory for entire job #25742 - GitHub
<job_id>.steps.run , using the working-directory keyword, you can specify the working directory of where to run the command.
Read more >
Configuring Github Actions in a multi-directory repository ...
The general idea was that you could set different working directories for specific jobs that you had to run in your workflow. So...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found