runner icon indicating copy to clipboard operation
runner copied to clipboard

Run script handlers with `ACTIONS_*` environment variables

Open blampe opened this issue 1 year ago • 0 comments

Refs https://github.com/actions/runner/issues/3046.

This runs script steps with ACTIONS_* environment variables in exactly the same way they are passed to Docker and Node steps.

By doing so, this reduces the need for steps like crazy-max/ghaction-github-runtime when programmatically consuming cache APIs (for example via tonistiigi/go-actions-cache).

Test workflow:

on:
  workflow_dispatch:

jobs:
  main:
    runs-on: self-hosted
    steps:
      - run: env | grep ACTION

Before this change:

2024-07-15T16:22:56.0537770Z Complete job name: main
2024-07-15T16:22:56.0976680Z ##[group]Run env | grep ACTION
2024-07-15T16:22:56.0977140Z [36;1menv | grep ACTION[0m
2024-07-15T16:22:56.1109490Z shell: /opt/homebrew/bin/bash -e {0}
2024-07-15T16:22:56.1110200Z ##[endgroup]
2024-07-15T16:22:56.1625900Z GITHUB_ACTION=__run
2024-07-15T16:22:56.1626460Z GITHUB_ACTIONS=true
2024-07-15T16:22:56.1626900Z GITHUB_ACTION_REPOSITORY=
2024-07-15T16:22:56.1627290Z GITHUB_ACTION_REF=
2024-07-15T16:22:56.1692500Z Cleaning up orphan processes

After this change:

2024-07-15T16:19:49.4702740Z Complete job name: main
2024-07-15T16:19:49.5223750Z ##[group]Run env | grep ACTION
2024-07-15T16:19:49.5224190Z [36;1menv | grep ACTION[0m
2024-07-15T16:19:49.5284960Z shell: /opt/homebrew/bin/bash -e {0}
2024-07-15T16:19:49.5285720Z ##[endgroup]
2024-07-15T16:19:49.5671290Z GITHUB_ACTION=__run
2024-07-15T16:19:49.5672240Z ACTIONS_CACHE_URL=https://acghubeus1.actions.githubusercontent.com/***/
2024-07-15T16:19:49.5672970Z GITHUB_ACTIONS=true
2024-07-15T16:19:49.5673720Z ACTIONS_RUNTIME_URL=https://pipelinesghubeus8.actions.githubusercontent.com/***/
2024-07-15T16:19:49.5674680Z ACTIONS_RESULTS_URL=https://results-receiver.actions.githubusercontent.com/
2024-07-15T16:19:49.5699210Z ACTIONS_RUNTIME_TOKEN=***
2024-07-15T16:19:49.5699910Z GITHUB_ACTION_REPOSITORY=
2024-07-15T16:19:49.5700310Z GITHUB_ACTION_REF=
2024-07-15T16:19:49.5765400Z Cleaning up orphan processes

blampe avatar Jul 15 '24 16:07 blampe