-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using a shared image across job boundaries. This is a follow-up to ADDSRV-720. docker-build uploads a compressed image artifact. docker-run downloads and extracts the image artifact. Then runs whatever commands you specify on the image.
- Loading branch information
Showing
3 changed files
with
101 additions
and
31 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: 'Docker Run Action' | ||
description: 'Run a command in a new container' | ||
inputs: | ||
image: | ||
description: "The Docker image to run" | ||
required: true | ||
options: | ||
description: 'Options' | ||
required: false | ||
run: | ||
description: 'Run command in container' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
############################################################################################### | ||
# These steps are synchronized between run-docker and build-docker. They produce the same values | ||
# If run on a single workflow and allow a single docker build to be run across N jobs. | ||
# If you modify these values, you must modify the corresponding values in both | ||
- name: Define Artifact Path | ||
id: artifact | ||
shell: bash | ||
run: | | ||
# These need to be kept in sync with the build-docker action | ||
DIR=/tmp | ||
FILE=artifact.tar | ||
NAME="$(git rev-parse --short HEAD)" | ||
echo "dir=$DIR" >> "$GITHUB_OUTPUT" | ||
echo "file=$FILE" >> "$GITHUB_OUTPUT" | ||
echo "path=$DIR/$FILE" >> "$GITHUB_OUTPUT" | ||
echo "name=$NAME" >> "$GITHUB_OUTPUT" | ||
############################################################################################### | ||
|
||
- name: Download artifact | ||
id: download | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ steps.artifact.outputs.name }} | ||
path: ${{ steps.artifact.outputs.dir }} | ||
|
||
- name: Load Docker image | ||
shell: bash | ||
run: | | ||
docker load --input ${{ steps.artifact.outputs.path }} | ||
- name: Run Docker Container | ||
shell: bash | ||
run: | | ||
echo "${{ inputs.run }}" > exec.sh | ||
chmod +x exec.sh | ||
cat exec.sh | docker run -i --rm ${{ inputs.image }} bash |
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