-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action does not relay that host has docker installed #5
Conversation
Thank you very much for the contribution. My understanding is that an action that runs using Docker is only compatible with Linux runners, and therefore this change would remove Windows and macOS compatibility from the action.
Perhaps if you can describe your use-case we can come up with a solution that is cross-platform: is there a reason you're using a runner that doesn't have docker installed (and can't have docker installed)? |
:) It looks something like:
|
@buildsecurity-kfir Thank you very much for the follow-up with clarity on your use-case. According to the GitHub documentation:
Therefore your example is equivalent to this: jobs:
api_test:
runs-on: ubuntu-latest
timeout-minutes: 30
- container: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.12
steps:
- name: Checkout
+ container: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.12
uses: actions/checkout@v2
- name: Copy dependencies
+ container: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.12
id: extract
uses: buildsecurity-kfir/actions-docker-extract@v1.0.4
with:
image: 'image'
path: 'path/file'
- name: Run tests
+ container: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.12
env:
FILE_PATH: '${{ steps.extract.outputs.destination }}/file'
run: |
echo "Run tests" This means that each of your step is running inside of the dotnet alpine container, unless your step uses a Docker action which forces GitHub to ignore your Jobs and dependencies between jobs are a great way to achieve this, for example, you could have a jobs:
dependencies:
runs-on: ubuntu-latest
outputs:
extracted: ${{ steps.artifacts.outputs.destination }}
steps:
- uses: shrink/actions-docker-extract@v1
id: artifacts
with:
image: 'ghost:alpine'
path: '/var/lib/ghost/current/core/built/assets/.'
test:
runs-on: ubuntu-latest
container: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.12
needs: [dependencies]
steps:
- uses: actions/checkout@v2
- name: Run Tests
env:
FILE_PATH: '${{ needs.dependencies.outputs.extracted }}/file'
run: |
echo "Run tests" This approach will give you the flexibility to grow your workflows over time so that you can continue to use actions that do not run in Docker :-) As an aside, I'd recommend containerising your application: running tests inside your application container as part of the build process will greatly improve developer experience. I have an example project called Laravel Strict which implements the pattern (see Dockerfile and build.yaml). Let me know if you need any more guidance, or if any aspect of what I've described here is unclear: if there's an aspect of this use-case that I've missed that requires Docker, we could look at publishing two versions of this action. |
Thanks a lot for the detailed respond It worth to mention that in order to share artifacts I used actions/upload-artifact@v2 and actions/download-artifact@v2. Thanks a lot. |
I'm glad to hear that it's working for you now! I'll close this Pull Request now, but please feel free to create a new issue if you encounter any further issues.
That's a great idea, I'll add some additional documentation covering your use-case. |
Changed implementation such that the action would run on docker
This allows the step to run and succeed to copy when docker is not installed on the hosting container