Move workflows into .github dir as required by spec #1
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: Run command in docker container and upload artifact if created | |
on: | |
workflow_call: | |
inputs: | |
image-target: | |
description: 'The build step target of the docker image' | |
type: string | |
command: | |
description: 'The command to run using the built docker image' | |
required: true | |
type: string | |
additional-run-args: | |
description: 'Any additional args to pass to the docker run subcommand' | |
type: string | |
docker-path-to-copy-from: | |
description: 'If this is given the contents of the path will be copied to the host' | |
required: true | |
default: '' | |
type: string | |
host-path-to-copy-to: | |
description: 'The host path to copy the contents of the docker location specified in the docker-path-to-copy-from arg to' | |
required: true | |
type: string | |
jobs: | |
run-in-docker: | |
name: Run cmd | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get app version | |
id: get-app-version | |
uses: infoxchange/github-ci/actions/get-app-version | |
- name: Setup docker image | |
id: setup-docker-image | |
uses: infoxchange/github-ci/actions/setup-docker-image | |
with: | |
target: ${{ inputs.image-target }} | |
build-args: | | |
APP_VERSION=${{ steps.get-app-version.outputs.app-version }} | |
- name: Run docker with optional file extraction | |
shell: bash | |
if: ${{ inputs.docker-path-to-copy-from }} | |
run: | | |
CONTAINER_ID=$( \ | |
docker create -t ${{ steps.setup-docker-image.outputs.image-name }} \ | |
${{ inputs.additional-run-args }} \ | |
${{ inputs.command }} \ | |
) | |
docker start -a "$CONTAINER_ID" && exitCode=$? || exitCode=$? | |
docker cp "$CONTAINER_ID:${{ inputs.docker-path-to-copy-from }}" \ | |
${{ inputs.host-path-to-copy-to }} || true | |
exit $exitCode | |
- name: Upload artifact | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Mocha maps - screenshots | |
path: testing-screenshots | |
if-no-files-found: ignore |