Closed danra closed 1 month ago
I would suggest to add a step which pipes the string x-access-token:${{ steps.app-token.outputs.token }} | bash64
Unfortunately, that's not cross-platform (doesn't work on Windows). I used github-script for cross-platform base64 encoding:
- name: Prepare basic auth credentials
id: basic-auth-creds
uses: actions/github-script@v7
with:
script: return btoa("x-access-token:${{ steps.app-token.outputs.token }}")
result-encoding: string
- name: Checkout with private submodules
env:
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: http.https://github.com/.extraheader
GIT_CONFIG_VALUE_0: "AUTHORIZATION: basic ${{ steps.basic-auth-creds.outputs.result }}"
# Access allowed to private submodules in the current owner's installation
run: git clone --recurse-submodules --shallow-submodules https://github.com/${{ github.repository }}
In future, can you please create an issue first before a pull request? We appreciate the effort you put into it, but having a discussion first might help prevent unnecessary work and frustration.
Sure, no worries. I'll close the PR. A README addition would be helpful, indeed.
This allows using the encoded token for basic auth-based git access.
This is useful for scripts expecting to be able to access private git repos. My specific case was using CPM.cmake in a repo that brings in other private repos as dependencies.
While the encoding to make this work is very simple, the documentation for it is sparse and it is not trivial to figure out, so there's value in providing this out of the box.