I need to do some directory grooming before my app is ready to be tested or deployed. I would like to utilize a Makefile target which calls a shell script in the repo to make this CI/CD-agnostic. One can call this target with make prepare_directory
The CI platform I am using is Github Actions. Here are the relevant parts of the workflow which is being run on new Pull Requests:
name: PR Tests
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Prep directoy
run: make prepare_directory
Here is the relevant part of the Makefile (which works exactly as expected locally):
...
prepare_directory:
./scripts/prepare_directory.sh
clean:
@rm -Rf ./$(BUILDPREFIX)
.PHONY: all clean docker lint prep_avro $(dockerbuilds)
Here is the relevant part of the ./scripts/prepare-directory.sh script:
#!/bin/bash -e
# ...
# clone repo using https and GITHUB_TOKEN
git clone https://[email protected]:USERNAME/REPO.git
When I try to clone using that URL, from the shell script, the script fails (along with the Github workflow pipeline) with the following error: fatal: unable to access 'https://github.com:USERNAME/REPO.git/': URL using bad/illegal format or missing URL
Does anybody know what I'm doing wrong?
I've created a GitHub App and Github Action to workaround these limitations GitHub Actions Access Manager. Feel free to drop some feedback.

.github/access.yaml file in Target Repository..github/access.yaml file from Target Repository and determine which permissions should be granted to Requesting Repository, authorized by the GitHub App Installation Token from step 2..1..$GITHUB_ACCESS_TOKEN and as step output value ${{ steps.github-actions-access.outputs.token }}.
answered Sep 06 '26 19:09
The URL in your prepare-directory.sh script's git clone call has a typo in it:
# clone repo using https and GITHUB_TOKEN
git clone https://[email protected]:USERNAME/REPO.git
The URL there is halfway between an HTTPS git URL and an SSH one. The : should be a /. Assuming your $GIT_TOKEN contains just the token and nothing else, you'd also need a : before the @:
git clone https://$GIT_TOKEN:@github.com/USERNAME/REPO.git
If your $GIT_TOKEN contained the complete auth string, which for a Github App installation access token would be something like "x-access-token:ghs_..." then you wouldn't need the : following $GIT_TOKEN, you'd just have [email protected].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With