OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to fetch the dynamic value from the github action and use it further

  • Thread starter Thread starter Pawan Singhania
  • Start date Start date
P

Pawan Singhania

Guest
New to github action and I am trying to fetch a variable from the previous step and use it further how to do it ?

My sample YAML File:

Code:
---
  name: Snyk Scan for Test
  on:
    push:
      branches:
        - main
  jobs:
    security:
      runs-on: ubuntu-latest
      steps:
        - name: Checkout code
          uses: actions/checkout@v2
        - name: Install dependencies
          run : npm i
        - name: Run Snyk to check for vulnerabilities
          id  : snyk_scan
          uses: snyk/actions/node@master
          env :
            SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
          with:
            command: monitor
        - name: Extract Snyk URL
          id: extract_snyk_url
          run: echo "URL=VALUE" >> $(echo '${{ steps.snyk_scan.outputs.stdout }}' | grep -o 'https://app.snyk.io/org<test_repo>/history/[a-zA-Z0-9\-]\+')

From the above file when I am running it I am getting the following result,

Code:
Run snyk/actions/node@master
/usr/bin/docker run --name snyksnyknode_20650d --label ab5c16 --workdir /github/workspace --rm -e "SNYK_TOKEN" -e "INPUT_COMMAND" -e "INPUT_ARGS" -e "INPUT_JSON" -e "FORCE_COLOR" -e "SNYK_INTEGRATION_NAME" -e "SNYK_INTEGRATION_VERSION" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/<code_repo>/<code_repo>":"/github/workspace" snyk/snyk:node  "snyk" "monitor" ""
Monitoring /github/workspace (<code_repo> Test Suite)...
Explore this snapshot at https://app.snyk.io/org/<repo_details>/history/566241c0-c5j2-4506-a86b-8e61jp4783b3
Tip: Detected multiple supported manifests (1), use --all-projects to scan all of them at once.
Notifications about newly disclosed issues related to these dependencies will be emailed to you.

`

I am trying to fetch the url value from Explore this snapshot at https://app.snyk.io/org/<repo_details>/history/566241c0-c5j2-4506-a86b-8e61jp4783b3. How do it ? I am trying but not able to fetch it.

Tried with set-output but is it depricating, anyway I can solve it ?
<p>New to github action and I am trying to fetch a variable from the previous step and use it further how to do it ?</p>
<p>My sample YAML File:</p>
<pre><code>---
name: Snyk Scan for Test
on:
push:
branches:
- main
jobs:
security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run : npm i
- name: Run Snyk to check for vulnerabilities
id : snyk_scan
uses: snyk/actions/node@master
env :
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
- name: Extract Snyk URL
id: extract_snyk_url
run: echo "URL=VALUE" >> $(echo '${{ steps.snyk_scan.outputs.stdout }}' | grep -o 'https://app.snyk.io/org<test_repo>/history/[a-zA-Z0-9\-]\+')
</code></pre>
<p>From the above file when I am running it I am getting the following result,</p>
<pre><code>Run snyk/actions/node@master
/usr/bin/docker run --name snyksnyknode_20650d --label ab5c16 --workdir /github/workspace --rm -e "SNYK_TOKEN" -e "INPUT_COMMAND" -e "INPUT_ARGS" -e "INPUT_JSON" -e "FORCE_COLOR" -e "SNYK_INTEGRATION_NAME" -e "SNYK_INTEGRATION_VERSION" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/<code_repo>/<code_repo>":"/github/workspace" snyk/snyk:node "snyk" "monitor" ""
Monitoring /github/workspace (<code_repo> Test Suite)...
Explore this snapshot at https://app.snyk.io/org/<repo_details>/history/566241c0-c5j2-4506-a86b-8e61jp4783b3
Tip: Detected multiple supported manifests (1), use --all-projects to scan all of them at once.
Notifications about newly disclosed issues related to these dependencies will be emailed to you.
</code></pre>
<p>`</p>
<p>I am trying to fetch the <code>url</code> value from <code>Explore this snapshot at https://app.snyk.io/org/<repo_details>/history/566241c0-c5j2-4506-a86b-8e61jp4783b3</code>. How do it ? I am trying but not able to fetch it.</p>
<p>Tried with <code>set-output</code> but is it depricating, anyway I can solve it ?</p>
Continue reading...
 

Latest posts

Top