1

I want to run my workflow in a container from private Docker registry:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: my-registry.net/my-image:latest
    steps:
      - ...

Now my docker registry is internal and can be accessed via vpn. So I thought I'd have a workaround by running another job that pulls the image:

jobs:
  tailscale:
    runs-on: ubuntu-latest
    steps:
      - name: Connect to Tailscale
        uses: tailscale/github-action@v1
        with:
          authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
          version: 1.18.2
      - name: Login to Private Container Registry
        uses: docker/login-action@v1
        with:
          registry: my-registry.net
          username: ${{ secrets.REGISTRY_USER }}
          password: ${{ secrets.REGISTRY_PASSWORD }}
      - name: Pull Image
        run: docker pull my-registry.net/my-image:latest
  build:
    needs: tailscale
    runs-on: ubuntu-latest
    container:
      image: my-registry.net/my-image:latest
    steps:
      - ...

However, this solution doesn't work because GitHub doesn't use the same runner for different jobs, as discussed here. How do I go about this without using my own runners?

gmode
  • 3,601
  • 4
  • 31
  • 39

1 Answers1

0

Create an action with your "connecting" code and reuses it because without using your own runner, you need to connect every time in your VPN to get access to your registry.

fguisso
  • 42
  • 5
  • 1
    I cannot run an action before my job starts. There are no pre-job steps – gmode Jul 08 '22 at 15:56
  • Actions can be put into steps in any position, like you are using the tailscale/github-action and docker/login-action. `steps` are commands inside machine/container, `jobs` running in different machines/containers – fguisso Jul 14 '22 at 17:24
  • 1
    I'm not sure I'm following. I cannot run a step before a job starts (on the same machine). At the moment I don't see a way to connect to tailscale before the image is pulled from private Docker registry – gmode Jul 15 '22 at 11:53