My use-case: I have private GitHub repository and private GitHub NPM registry for dependencies. Repository imports dependencies from private registries. For GitHub actions CI pipeline, GitHub generates a temporary token, which could be used to access this registry; in GH actions I can set up the private registry for Docker build using this token:
RUN npm config set @orgname:registry https://npm.pkg.github.com && \
echo "//npm.pkg.github.com/:_authToken=${NPM_REGISTRY_TOKEN}" >> $HOME/.npmrc && \
npm ci
GH actions workflow step:
- name: Docker build
run: docker build --build-arg NPM_REGISTRY_TOKEN=${{ secrets.GITHUB_TOKEN }} .
I want to build the same Docker image in AWS CodeBuild. I created GitHub connection via OAuth app and configured build spec, but I can't find how to get GitHub OAuth token from this connection.
But I don't want to use personal access token for this because it gives too broad access to unrelated resources (repository and registry are located in GH org, PAT gives access to my personal GH account).
Is it possible to access some temporary GH token from CodeBuild environment?