Setting git global config not working for using PAT token
ankitatdnv opened this issue · comments
Describe the bug
After setting git global config to use PAT token for all request on github is not working with terragrunt-action.
Please find below the code snippet:
- name: Github InsteadOf setup
run: |
git config --global url."https://username:${{env.PAT_TOKEN}}@github.com".insteadOf "https://github.com"
- name: Terragrunt Init
uses: gruntwork-io/terragrunt-action@v1.0.1
with:
tg_version: ${{ env.TERRAGRUNT_VERSION }}
tf_version: ${{ env.TERRAFORM_VERSION }}
tg_dir: ${{ env.working-directory }}
tg_command: "init"
To Reproduce
Steps to reproduce the behavior, code snippets and examples which can be used to reproduce the issue.
Try to use a private repository as source of terraform module using github PAT token
terraform code:
module "app" {
source = "github.com/org-name/repo.git//path/to/module?ref=branch"
}
Github action code:
- name: Github InsteadOf setup
run: |
git config --global url."https://username:${{env.PAT_TOKEN}}@github.com".insteadOf "https://github.com"
- name: Terragrunt Init
uses: gruntwork-io/terragrunt-action@v1.0.1
with:
tg_version: ${{ env.TERRAGRUNT_VERSION }}
tf_version: ${{ env.TERRAFORM_VERSION }}
tg_dir: ${{ env.working-directory }}
tg_command: "init"
Expected behavior
I should be able to use private github repository as source of terraform modules
Nice to have
- Terminal output:
│ fatal: could not read Username for 'https://github.com/': No such device or address
- Screenshots
Versions
- Terragrunt Action version: 1.0.1
- Environment details (Terragrunt version, Terraform version, etc.): terragrunt-version: 0.48.1, terraform-version: 1.5.2
Additional context
Add any other context about the problem here.
Hello,
changes performed outside of workspace directory aren't passed to action container, in the current case git config --global ...
change contents of /home/runner/.gitconfig
However, since version 1.0.2 can be passed environment variables with scripts which will be executed before running Terragrunt, and can be passed git config --global
command
Example:
...
- name: Plan
uses: gruntwork-io/terragrunt-action@v1
env:
INPUT_PRE_EXEC_1: |
git config --global url."https://denis256:${{secrets.PAT_TOKEN}}@github.com".insteadOf "https://github.com"
with:
tf_version: ${{ env.tf_version }}
tg_version: ${{ env.tg_version }}
tg_dir: ${{ env.working_dir }}
tg_command: 'run-all plan --terragrunt-log-level debug'
...
References:
https://github.com/gruntwork-io/terragrunt-action/releases/tag/v1.0.2
https://github.com/denis256/tg-gh-action-examples/blob/master/.github/workflows/private-repo.yml#L31