Open stumelius opened 2 years ago
I have configured the working-directory at the workflow level if that's of any importance here.
Might be the reason as we do not use this variable:
Having said that, I expect GitHub Action to execute the annotations-action in the working-directory
so fs.readFile('./annotations.json', { encoding: 'utf8' })
should work...
Did you try to explicitly set the working-directory
on the task? or use the relative path from the root in input
?
Thanks! I just fixed it by including my working directory in the input path.
For some reason this action is not run in the working directory or there's some other reason why the working-directory is not applied to it
For some reason this action is not run in the working directory or there's some other reason why the working-directory is not applied to it
It sounds like a bug/limitation of GitHub Actions.
In my opinion, actions should not have to explicitly set the working directory, so the code seems correct: fs.readFile(inputPath, { encoding: 'utf8' })
. Does it work if you explicitly define the working-directory
on the step?
- name: Annotate SQL linting errors
uses: yuzutech/annotations-action@v0.4.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title: lint
input: './annotations.json'
working-directory: 'some/path'
You should open a support ticket at: https://support.github.com/features/actions
It looks like jobs with uses
don't support the working-directory
argument. I got an error from the Github actions validator but didn't find much from quick googling. Just this https://github.community/t/use-working-directory-for-entire-job/16747/4
I think that it also doesn't take into account that annotations paths can be nested relative to working directory as well.
Consider following workflow
name: example_app
on:
pull_request:
paths:
- ".github/workflows/example_app.yaml"
- "example/lib/**"
jobs:
build:
defaults:
run:
working-directory: ./example
runs-on: ubuntu-latest
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v3
...
- name: 🧪 Evaluate
run: generate_annotations > ./annotations.json
- name: 🕵️ Debug
run: cat ./annotations.json
- name: Annotate
uses: yuzutech/annotations-action@v0.4.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title: "lint"
ignore-missing-file: false
input: "./example/annotations.json"
The output can be:
[
{
"path": "lib/main_development.dart",
"start_line": 9,
"end_line": 9,
"annotation_level": "notice",
"message": "My message"
}
]
So the real path would be example/lib/main_development.dart
.
I wonder what is valid and what would be expected by users:
annotations-action
should take that into account while calling GH apisthe annotations should always be generated with full paths, not relative to a working directory
I think that's the safer approach.
the annotations should be generated with paths relative to working directory, and the annotations-action should take that into account while calling GH apis
Not sure if the GitHub Action has access to the working-directory
configuration...
I'm getting a
Ignoring missing file at 'annotations.json' because 'ignore-missing-file' is true
error in my workflow:The "Print annotations" step is printing out the annotations but the "Annotate SQL linting errors" step does not find the file. What am I missing here? I have configured the
working-directory
at the workflow level if that's of any importance here.