{"meta":{"title":"Setting a default shell and working directory","intro":"Define the default settings that will apply to all jobs in the workflow, or all steps in a job.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/how-tos","title":"How-tos"},{"href":"/en/actions/how-tos/write-workflows","title":"Write workflows"},{"href":"/en/actions/how-tos/write-workflows/choose-what-workflows-do","title":"Choose what workflows do"},{"href":"/en/actions/how-tos/write-workflows/choose-what-workflows-do/set-default-values-for-jobs","title":"Set default values for jobs"}],"documentType":"article"},"body":"# Setting a default shell and working directory\n\nDefine the default settings that will apply to all jobs in the workflow, or all steps in a job.\n\n## Overview\n\nUse `defaults` to create a `map` of default settings that will apply to all jobs in the workflow. You can also set default settings that are only available to a job. For more information, see [`jobs.<job_id>.defaults`](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_iddefaults).\n\nWhen more than one default setting is defined with the same name, GitHub uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.\n\n## Setting default shell and working directory\n\nYou can use `defaults.run` to provide default `shell` and `working-directory` options for all [`run`](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsrun) steps in a workflow. You can also set default settings for `run` that are only available to a job. For more information, see [`jobs.<job_id>.defaults.run`](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_iddefaultsrun). You cannot use contexts or expressions in this keyword.\n\nWhen more than one default setting is defined with the same name, GitHub uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.\n\n### Example: Set the default shell and working directory\n\n```yaml\ndefaults:\n  run:\n    shell: bash\n    working-directory: ./scripts\n```\n\n## Setting default values for a specific job\n\nUse `jobs.<job_id>.defaults` to create a `map` of default settings that will apply to all steps in the job. You can also set default settings for the entire workflow. For more information, see [`defaults`](/en/actions/reference/workflows-and-actions/workflow-syntax#defaults).\n\nWhen more than one default setting is defined with the same name, GitHub uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.\n\n## Setting default shell and working directory for a job\n\nUse `jobs.<job_id>.defaults.run` to provide default `shell` and `working-directory` to all `run` steps in the job.\n\nYou can provide default `shell` and `working-directory` options for all [`run`](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsrun) steps in a job. You can also set default settings for `run` for the entire workflow. For more information, see [`defaults.run`](/en/actions/reference/workflows-and-actions/workflow-syntax#defaultsrun).\n\nThese can be overridden at the `jobs.<job_id>.defaults.run` and `jobs.<job_id>.steps[*].run` levels.\n\nWhen more than one default setting is defined with the same name, GitHub uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.\n\n### Example: Setting default `run` step options for a job\n\n```yaml\njobs:\n  job1:\n    runs-on: ubuntu-latest\n    defaults:\n      run:\n        shell: bash\n        working-directory: ./scripts\n```"}