Skip to content
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

Add a recreate credential option #31

Open
en-medina opened this issue Jun 12, 2024 · 2 comments
Open

Add a recreate credential option #31

en-medina opened this issue Jun 12, 2024 · 2 comments

Comments

@en-medina
Copy link

Hi, community 👋🏽

(I'm not sure if this is the correct way to ask about this)

While using this action, I encountered an issue inside a long-living self-hosted runner. I was generating a temporary GitHub app token with the actions/create-github-app-token@v1 action and then using this action to configure my git creds so I could perform some git clone commands on different repositories.

So the issue is that the first time I ran a job similar to the one found below, it worked without issue, but when I retried to run the job a second time it failed with an authentication error. While troubleshooting the runner I noticed that the action keeps the previously saved token on the /git/credentials file (that on this second run, this token was expired by the create-github-app-token post-action step). I solved the issue by removing this file at the beginning of the job, but I wanted to know if we could add an option to this action that removes this file for us (so other folks can avoid this issue).

name: My pipeline
on:
  push:
   branch:
   - main

jobs:
  my-job:
    runs-on: self-hosted
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: actions/create-github-app-token@v1
        id: app-token
        with:
          app-id: ${{ secret.PIPELINE_GH_ID }}
          private-key: ${{ secret.PIPELINE_GH_PRIV }}
          owner: "myorg"

      - name: Configure git credentials
        uses: de-vri-es/setup-git-credentials@v2
        with:
          credentials: https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/

      - name: Fetch myorg repos
        run: |
          git clone https://github.com/myorg/repoA.git
          git clone https://github.com/myorg/repoB.git
          git clone https://github.com/myorg/repoC.git
@de-vri-es
Copy link
Owner

de-vri-es commented Jun 12, 2024

Ah, interesting. I did not consider runners with persistent state. Thanks for bringing it up!

I think it should be possible to remove the added credentials and leave anything else in place.

@en-medina
Copy link
Author

yeah in this case I added a previous step with this action. If you like I can create a pull request with a comment about this on the README.md file.

      - name: Clean git credentials
        run: |
          rm -rf ~/.config/git/credentials || true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants