Created
November 7, 2024 21:23
-
-
Save joshschmelzle/eb6af897721beddae6ca28cc4db91846 to your computer and use it in GitHub Desktop.
Get and use output from docker in GHA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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