3

I'm trying to use $GITHUB_OUTPUT instead of set-output.

I set up a simple GitHub Action with a docker file based on the official tutorial.

# Container image that runs your code
FROM alpine:latest

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]

And the entrypoint.sh is

#!/bin/sh -l

time=$(date)
echo "time=$time" >> $GITHUB_OUTPUT

Executing this in a Self hosted Debian runner results into a

/entrypoint.sh: 4: cannot create : Directory nonexistent

Changing the $GITHUB_OUTPUT with the usual ::set-output works correctly.

Any idea on how to solve this?

Jorge
  • 55
  • 4

3 Answers3

1

The deprecation of set-output was mentioned recently (oct. 2022)

If you are using self-hosted runners make sure they are updated to version 2.297.0 or greater.

So check first the version of your runner.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Well, yes, the version of the runner is probably one issue.

The other is that the environment variables defined in the shell that creates and runs the container that previously echo "::set-output..." do not have access to GITHUB_OUTPUT unless specifically configured to do so. Moreover, the paths within the container are not the same as that outside, so the path in $GITHUB_OUTPUT won't be available anyway.

The fastest workaround is to add >> $GITHUB_OUTPUT on the docker run command itself, ie. OUTSIDE of the container, and just echo content in there to stdout.

David Nugent
  • 377
  • 5
  • 7
0

Instead of using $GITHUB_OUTPUT, I unpacked the arbitration by creating a temporary file.

before:

time=$(date)
echo "time=$time" >> $GITHUB_OUTPUT

after:

echo $(date) > time
docker build -t example:$(cat time)

The above method can be applied.

K DoKy
  • 11
  • 2