Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Created November 7, 2024 21:23
Show Gist options
  • Save joshschmelzle/eb6af897721beddae6ca28cc4db91846 to your computer and use it in GitHub Desktop.
Save joshschmelzle/eb6af897721beddae6ca28cc4db91846 to your computer and use it in GitHub Desktop.
Get and use output from docker in GHA
name: Get Output from Docker
on:
workflow_dispatch:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare output file
run: |
touch output.env
- name: Run Alpine docker container
id: run-docker
run: |
docker run --rm \
-v ${{ github.workspace }}/output.env:/output.env \
alpine \
/bin/sh -c "echo 'hello=\"hello world\"' >> /output.env && echo 'thing=\"some thing\"' >> /output.env && echo 'test=\"this\"' >> /output.env"
- name: Load and use output as environment variable
run: |
source output.env
echo "hello is $hello"
echo "thing is $thing"
echo "test is $test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment