Got it.
For anyone wondering how to pull private repositories during mix.compile using the docker-build-push GitHub action:
Create Access Token
Create a Personal Access Token (Sign in to GitHub · GitHub ; Navigation: Profile > Settings > Developer Settings > Personal Access Tokens > Fine Grained Tokens). It should be able to read repositories you have access to.
Consider using a “machine user”, as in a normal user account that was created just for the purpose of holding your tokens, if you are an organisation.
Add token as Secret
Create a secret in your organisation or repository, e.g. CI_ACCESS_TOKEN. (Repo: Settings > Secrets and Variables > Actions). Put in your previously created token. I made the mistake of adding it to an “environment” by accident at first and wondered why it was not working as intended.
Set up workflow file
In your github workflow file:
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ...
secrets: |
GIT_AUTH_TOKEN=${{ secrets.CI_ACCESS_TOKEN }}
Dockerfile
in your Dockefile, grab the secret, configure git, get the deps:
RUN --mount=type=secret,id=GIT_AUTH_TOKEN \
GIT_AUTH_TOKEN=$(cat /run/secrets/GIT_AUTH_TOKEN) \
&& git config --global "url.https://${GIT_AUTH_TOKEN}@github.com.insteadof" "https://github.com" \
&& mix deps.get --only $MIX_ENV






















