Comments (8)
I don't think that is equivalent, e.g. how can we make the github actions testable, especially for forks.
from typescript-action.
Hello!
Apologies for the delay in responding to this issue. Currently, referencing the action locally will not let the pre
step run. However, as a workaround, you can reference the local action by specifying the repository and path. For example, if your repository contains an action that looks like the following (index.js
is the main
script and setup.js
is the pre
script):
my-action
├── action.yml
├── index.js
├── package-lock.json
├── package.json
└── setup.js
You could reference the action in a workflow file like this:
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: <owner>/<repo>/my-action@main
This should let pre
script run as expected!
from typescript-action.
This workaround makes it impossible to test changes to an action in the repo in which it's developed, which I imagine is a very common use case for folks who are writing and referencing local actions. It'd work if one could write - uses: <owner>/<repo>/my-action@${{ github.sha }}
, but that's not allowable.
Can someone from GitHub explain why pre:
and friends aren't supported for local actions?
from typescript-action.
I did some checking internally to see why pre
is not supported for local actions. The reason is because the action itself is downloaded and run after the job starts and any pre
steps have run. On the other hand, post
does work when referencing local actions.
As far as testing the action, you should be able to reference either your fork repo or branch name without issue:
- uses: <owner>/<fork-repo>@main
- uses: <owner>/<action-repo>@<feature-branch>
Are there specific errors you're running into when testing actions in a fork or branch? I'd be happy to dig into it if you have a reproducible example
from typescript-action.
Closing due to lack of activity. If you'd like to revisit this please open a new issue and provide any additional details that may be useful :)
from typescript-action.
There is no activity because the request is clear. We need it for relative path. That's the form that works for gh actions to allow PRs, otherwise whenever a new PR is made, they need to point the unit tests to their fork, run the tests and point them back to the original repo before merging
from typescript-action.
Apologies! I misunderstood the request :/
I was able to find more info here. In particular:
Action referenced from local repository (./my-action
) won't get pre
setup correctly since the repository haven't checked-out during job initialization. We can't use GitHub api to download the repository since there is about a 3 minute delay between git push and the new commit available to download using GitHub api.
As far as current workarounds, yes you can fork the action repo, update the workflow to reference the forked repo name, and then update to the original repo name before submitting the PR.
Another option would be to convert to a composite action and move the pre
/post
steps into the "actual" workflow steps. E.g. instead of this:
runs:
using: 'node12'
pre: 'lib/setup.js'
main: 'lib/main.js'
-
Convert the
pre
step to it's own actionname: Setup Pre Action description: Setup Pre Action runs: using: node20 main: ../lib/pre.js
-
Convert the
main
step to a separate actionname: Main Action description: Main Action runs: using: node20 main: ../lib/index.js
-
Call both actions in a composite
name: Composite Action description: A composite action for demo purposes runs: using: composite steps: # This was previously a `pre` step in a Node.js action - name: Setup uses: ./setup-action # This was previously a `main` step in a Node.js action - name: Main uses: ./main-action
I created a trivial reproduction here if that helps. The benefit there is you shouldn't need to rename anything when forking and making updates.
from typescript-action.
We can't use GitHub api to download the repository since there is about a 3 minute delay between git push and the new commit available to download using GitHub api.
Sorry, but this sounds luke bs on their side. Why can't the pre be delayed for after git checkout, and why would the delay not have a similar effect on the repo reference approach?
Another option would be to convert to a composite action and move the pre/post steps into the "actual" workflow steps
That is the approach I've converged to, but I don't like it because it wraps all of the stdout to composite-like output.
from typescript-action.
Related Issues (20)
- draft-ietf-httpbis-p3-payload-14 HOT 1
- .eslintrc.json is badly formatted HOT 1
- Keep dependencies up to date HOT 1
- ESLint config should extend from recommended configurations HOT 1
- Template not compatible with latest Node.js LTS version (18.14.2) HOT 1
- This Template seems to be code rotting 😢 HOT 2
- - name: Glo Add Label To Cards HOT 1
- Cannot remove "main" from package.json in favor of "exports" HOT 8
- [error] No files matching the pattern were found: "'**/*.ts'"
- tsconfig module value triggers validation
- This sample should be targeting node20
- Run is called before first test HOT 1
- "npm test" script eats failure-status (because "|| make-coverage-badge") HOT 2
- Pre & Post action config recommendation? HOT 2
- README should tell you to remove CODEOWNERS HOT 1
- Make the release script update the package.json version HOT 7
- Add bun.lockb to .gitignore HOT 3
- Make super linter report on summary page HOT 2
- README documentation for the release script HOT 1
- thankyou HOT 1
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 typescript-action.