12

The following is my yml file for Github Actions. I want to set the user of the docker to root for the following via the docker options (--user root) . How can I do this via Github Actions?

name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: run zap
      uses: docker://sshniro/zap_action
      with:
        args: zap-baseline.py -t https://www.example.com

Thanks in Advance.

1 Answer 1

20

I don't think you can pass docker container arguments when using uses:, but you can set them with job containers.

Try this workflow:

name: ZAP
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: owasp/zap2docker-stable
      options: --user root
    steps:
      - uses: actions/checkout@v2
      - name: run zap
        run: zap-baseline.py -t https://www.example.com

You can find the documentation for the job.<job_id>.container syntax here.

1
  • This is not the same. It will run all steps in the docker container. This will break badly if you use e.g. Alpine, in which case you need the 'uses: docker://alpine' syntax. And that syntax is underdocumented as to how to pass additional arguments to docker.
    – hasufell
    Dec 8, 2022 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.