Comments (15)
@damccorm thanks for the quick reply!
I've confirmed if: job.steps.semantic.outputs.semantic_release_bool == 'true'
does not work. Let me know if you want me to set up another test for you guys. You should also be able to use the full snippet in the issue description to recreate.
IMO, it would make sense to be able to access the steps
context normally in an if
expression, same way we're able to access github
context for instance. Maybe there's a reason this isn't possible at the moment though.
That being said if I have to workaround that by accessing via the job
context that's not bad at all, but it seems as though only the status is made available to us, i.e. if: job.steps.<step id>.status == failure
and not the outputs.
FYI @ericsciple @thboop
from toolkit.
@codfish I actually have a PR to doc this right now - #105
To persist an output variable you can do echo ::set-output name=FOO::BAR
, to persist an env variable you can do echo ::set-env name=FOO::BAR
from toolkit.
Hey everyone, I have been watching this thread real-time and tested these changes and I can confirm it all works as of right now. Below is an example yaml file:
name: test
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Step 1
id: step1
run: echo "::set-output name=VAR1::Hamel"
- name: Step 2
id: step2
run: echo "::set-env name=VAR2::Husain"
- name: emit env
run: |
echo $VAR2
echo $VAR1
env:
VAR1: ${{ steps.step1.outputs.VAR1 }}
- name: this should not run
run: echo "This should not run"
if: steps.step1.outputs.VAR1 == 'Lucy'
This will give you the following output:
from toolkit.
Thanks for the write-up and detailed example @codfish!
We are working on making the steps context and their associated outputs(accessible via steps.<step id>.outputs.<output name>
) available inside a step's if statement. We'll make sure the docs reflect this as well, but this behavior isn't currently available.
@dakale, FYI, this is related to the steps context if statement behavior you were looking into.
from toolkit.
@codfish the pr is merged for the outputs issue. the fix will roll out with the next runner update. @TingluoHuang do you know when?
@hamelsmu steps.foo.status is not a thing today. i'll open a pr to remove that from the docs.
from toolkit.
later this week or really next week.
from toolkit.
Thanks @damccorm @thboop @ericsciple @dakale
Can confirm this is now working for me as well. https://github.com/codfish/actions-playground/blob/master/.github/workflows/release.yml#L48
much appreciated! You can close if you want
from toolkit.
I'm not sure where I should be posting this, or how I can report bugs, so I'm starting here. Please point me in the right direction if this isn't the forum
This isn't super well defined right now, we're working on clarifying that. Since this isn't an issue with the toolkit, it probably belongs here for now - with that said, we should have better avenues for feedback like this soon. For now, we can take this here.
Concerning the issue itself, I think that if: job.steps.semantic.outputs.semantic_release_bool == 'true'
should work, but I'm not totally sure. @ericsciple or @thboop do you know what the correct syntax is here? Are we plumbing all of this through yet?
from toolkit.
@thboop awesome, thanks for the update!
from toolkit.
Just to give some more context, the step with id second step
in the below yaml doesn't run even though it should, so I think there is a bug
on: push
jobs:
test-outputs:
name: Test Outputs Actions
runs-on: ubuntu-latest
steps:
- id: first_step
name: "This step will run no matter what."
run: echo 'the first step'
- name: Only run this step if another step succeeds
id: second_step
if: job.steps.first_step.status == success()
run: echo "Hello"
Also, I don't think the status is made available either as job.steps.<id>.status
consistently returns an empty/null value for me
from toolkit.
from toolkit.
@TingluoHuang @thboop @ericsciple wondering if you could answer a related question I have.
The only way I've found to properly set an environment variable (and an output var) is via @actions/core
library. I cannot figure out how to set one outside of js and have it persist. For instance, appending export SOME_VAR=foo;
to the runners' .bashrc
doesn't work.
I see you're using commands, i.e. set-env
here, but I'm not sure how that's working under the hood.
So is there a way to set and persist an env/output var from a host action or any other way without using the core package?
from toolkit.
@damccorm awesome, thank you!
@codfish the pr is merged for the outputs issue. the fix will roll out with the next runner update.
To clarify, will this PR include the ability to reference steps context & outputs in the if
property as well?
from toolkit.
@codfish That functionality is fixed in a separate PR, as mentioned above by Eric:
@codfish the pr is merged for the outputs issue. the fix will roll out with the next runner update. @TingluoHuang do you know when?
And should be released by end of week, maybe trickling into next week if there are issues duringthe release/rollout, per Ting:
later this week or really next week.
from toolkit.
I am trying to do something similar but instead of using constants 'Hamel' and 'Hussain' for var1 and var2, I want an expression to be evaluated. Concretely, the line looks as such -
echo "::set-env name=WEBSITE_BUCKET_ARN::$(terraform output website_bucket_arn)"
And when I echo the env variable in another step, I get "$WEBSITE_BUCKET_ARN" as a result. Any idea, leads or direction on how to store the result of an expression in an output/env variable. I have not been able to find anything related to this
When I try to access the environment variable WEBSITE_BUCKET
, and just echo it in another step, it does not work!
Hey everyone, I have been watching this thread real-time and tested these changes and I can confirm it all works as of right now. Below is an example yaml file:
name: test on: push jobs: build: runs-on: ubuntu-latest steps: - name: Step 1 id: step1 run: echo "::set-output name=VAR1::Hamel" - name: Step 2 id: step2 run: echo "::set-env name=VAR2::Husain" - name: emit env run: | echo $VAR2 echo $VAR1 env: VAR1: ${{ steps.step1.outputs.VAR1 }} - name: this should not run run: echo "This should not run" if: steps.step1.outputs.VAR1 == 'Lucy'
This will give you the following output:
from toolkit.
Related Issues (20)
- scoop install 1password-cli
- Dependencies: Public docs no longer match some API methods HOT 1
- Unix file permissions not stored in zip file HOT 1
- actions/cache assumes zstdmt to be installed HOT 1
- Cannot use `@actions/github` and `@actions/artifact` together
- Tracking
- @actions/artefacts weighs 100mb. this cant be right
- 2024 老牌机场推荐:老牌机场合集
- Bug: `context.job` fails to take into account `jobs.<job_id>.name` value HOT 2
- https://www.facebook.com/nara.istri.jisung
- `continue-on-error` should not return `success` in ` needs_job_result`
- Make uploadZipToBlobStorage() log raw and compressed sizes ?
- Annotations using environment files
- amin HOT 1
- npm i @actions/glob
- Bug
- Spacextool
- @actions/cache tar doesn't specify --xattrs
- @actions/github hasn't been published in 8 months
- Support storing and restoring cache entries as buffers. 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 toolkit.