Authenticating for packages when using another repo's action+package

I have a workflow that uses an action from a public repository I control. The action in turn uses its own docker image from docker.pkg.github.com. The following does not work, because it gives a -no basic auth credentials- error:

build-linux:
    runs-on: ubuntu-latest
    name: Linux
    steps:
    - name: Build
      uses: sot/skare3/actions/build@gh-actions

I have thought of doing something like this as work around:

jobs:
  build-linux:
    runs-on: ubuntu-latest
    name: Linux
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Login to GitHub Package Registry
      run: echo "${{ secrets.GITHUB_PKG_TOKEN }}" | docker login docker.pkg.github.com -u <user> --password-stdin
    - name: Build
      id: build
      uses: ./actions/build

with a dummy action that contains a Dockerfile like this:

FROM docker.pkg.github.com/sot/skare3/centos5-conda:1.0

Is that the best I can do? Is there no way to authenticate with docker.pkg.github.com before the action gets built? or during the action building process? I would not want to create this dummy action in every single project that uses the original action.

EDIT: after posting, I found this related postĀ https://github.community/t5/GitHub-Actions/Use-docker-images-from-GitHub-Package-Registry/td-p/30407

In the link I mentioned above, one comment provides a workaround better than mine and it works. It consists in pulling and running the docker image directly:

build-linux:
    runs-on: ubuntu-latest
    name: Linux
    steps:
    - name: Login to GitHub Package Registry
      run: docker login docker.pkg.github.com -u $GITHUB_ACTOR -p ${{ secrets.GITHUB_TOKEN }}
    - name: Pull Docker image
      run: docker pull docker.pkg.github.com/sot/skare3/centos5-conda:1.0
- name: Build
run: docker run --name builder -v $GITHUB_WORKSPACE:/github/workspace -w /github/workspacedocker.pkg.github.com/sot/skare3/centos5-conda:1.0

Still, it would be nice to be able to do it with the action.

1 Like