Comments (14)
I'm rewriting this comment as I have a feeling that this issue is actually a misinterpretation of the working_directory
option. It's rather confusing because Github seems to treat the working directory option as the place that data is going to be accessed and modified, and this action seems to treat it as something else entirely.
Please note that the following might be entirely wrong, it's just my interpretation.
If you're here because you want to use prettier
on a subdirectory in your repo
(ie. in my case, I have a Laravel instance at /api and a Vue instance at /app
. I use laravel-pint
for /api
so I wanted prettier for /app
)
- The
working_directory
option appears to be for something else, the README.md and code gives this away. - What you're looking for is the
prettier_options
option. - I might be incorrect with my implementation, but the following is a copy of my workflow.yml that's currently working for me:
name: Fix Code Style (App)
on:
workflow_dispatch:
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
# Make sure the value of GH_REPO_WRITE_TOKEN will not be persisted in repo's config
persist-credentials: false
- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --write /home/runner/work/repo_name/repo_name/working_directory/**/*.{js,jsx,ts,tsx,html,vue}
github_token: ${{ secrets.GH_REPO_WRITE_TOKEN }}
If you're here because you have a reason to want to install prettier to a specific directory on the runner
(which I believe the working_directory
option is for, although I'm pretty sure it's not working at the moment):
- The
working_directory
value requires absolute paths, and the path has to exist. That's why @Fatpandac was getting this error initially. I think the correct way to use it would either be to use an absolute path to an existing directory in your checked out repo, or to have a step above it that creates a folder somewhere else on the runner. - I'm not sure when this option would be useful, but based on the location
checkout
checked out to for me, I needed to enterworking_directory
path in the format:
/home/runner/work/repo-name/repo-name/working-directory-name
. - Once I got it working, I got this error:
/home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 74: prettier: command not found
- I'm thinking possible solutions to this would be to ensure prettier is in $PATH,
working_directory
possibly could be added to the prettier command instead ofcd
ing to the directory, or theentrypoint.sh
might need to be updated to use an./absolute/path/to/prettier
instead.
@creyD I can put together a pull request that will hopefully clear up this confusion if my interpretation is correct. Looks like it'd mostly consist of changes to the readme, although again I'm really not sure of a use case where the working_directory
option would be useful outside of specifically working on this action.
from prettier_action.
Thanks for the comment, sorry I didn't see it earlier. The working_directory option changes before prettier command is installed and sets the directory for the entire action. So yes, prettier is installed at the path you specify. That being said prettier_options can -like you showed- be used to specify directory as well. So it should actually work in my opinion.
@ParthS007 If you are still up to it (after such a long time) we should tackle this once and for all. I believe my autocorrect messed up when I wrote working-status
, I meant working_directory
. But I think you already tested it, right?
from prettier_action.
Can you please add your config and if the repo is public a link to the repo?
from prettier_action.
name: auto prettier
on:
push:
branches:
- feat/refactor_docs_site
paths:
- 'site-vuepress/**'
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Prettify code
uses: creyD/[email protected]
with:
working_directory: 'site-vuepress/'
same_commit: true
prettier_options: --write .
repo link: https://github.com/Fatpandac/arthas
from prettier_action.
@creyD Same is happening , did you had the time to look into this?
Some info that might help:
I have another workflow where I use the working-directory
variable and it works fine with ./ui
directory. Maybe some where in the code where you parse the arg to working-directory
. Thanks for your time.
@Fatpandac Do you have a workaround for this already?
from prettier_action.
@ParthS007 No idea. I give up on using working-directory
in the end.
from prettier_action.
Really sorry, I didn't find the time yet to look at this properly. Could you test please without the ''? So this would be working_directory: site-vuepress/
? @Fatpandac
from prettier_action.
Thank you so much for your reply to me again.
I do not need to work out this problem now.
You can help @ParthS007 to work out this problem.
from prettier_action.
@ParthS007 Could you please post your repo or the action config here?
from prettier_action.
@creyD Sure, Here's the workflow file:https://github.com/ParthS007/analysispreservation.cern.ch/blob/prettier/.github/workflows/ui-test.yml
and this is the latest workflow run: https://github.com/ParthS007/analysispreservation.cern.ch/runs/7575015767?check_suite_focus=true
Thanks for your time.
from prettier_action.
@creyD Any updates on this bug if you had the time to look into the issue. Thanks
from prettier_action.
Can you try with working-status: ui/
?
from prettier_action.
Thanks, The error is not there anymore but I see this warning:
Warning: Unexpected input(s) 'working-status', valid inputs are ['commit_message', 'commit_description', 'same_commit', 'commit_options', 'push_options', 'file_pattern', 'prettier_options', 'dry', 'prettier_version', 'working_directory', 'only_changed', 'prettier_plugins', 'github_token']
This is the workflow file.
Although, I see now only_changed
is not taken in consideration. I want to run this action only on changed files in the commit, It checks all code in the ui/
. Is this related or something not possible?
from prettier_action.
still waiting for fix this issue 🙄
from prettier_action.
Related Issues (20)
- [BUG] Problem running prettier in workflow HOT 5
- [BUG] Doesn't fail on infer parser failed HOT 4
- [BUG] Shouldn't delete node_modules HOT 8
- [BUG] Actions Fails to install/use modules - Cannot find module '@prettier/plugin-php'
- [BUG] Cannot find module 'prettier-plugin-tailwindcss' HOT 11
- [BUG] `prettier` not installed correctly HOT 9
- [BUG] prettier: command not found HOT 3
- [BUG] Problem --writer HOT 4
- [BUG] Process completed with exit code 1 HOT 5
- [BUG] Example not working. HOT 4
- IDEA: Add push_options parameter HOT 3
- [BUG] Error: Process completed with exit code 1 when using prettier-php HOT 12
- [BUG] Code style issues found, can't reproduce locally HOT 2
- [FEATURE] Format only changed lines not the whole file HOT 1
- [BUG] Should work when package-lock.json is not versioned HOT 3
- [FEATURE] Don't log unchanged files
- [BUG] Dry run fails in spite of the fact that a line length does not exceed 80 chars. HOT 2
- What is status code 128? HOT 5
- Readme out of date
- [FEATURE] Print the `prettier` command to be executed before executing it
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier_action.