0

I want to have an intermediate container in my workflow. Build in job 1 and then use it as service in job 2. I have tried the below already without success. In the second job I want to run tests against the built container. As an alternative, could I do a docker run in the second job and then connect it to the services' network? Which is?

name: Test

on:
  - pull_request

jobs:
  build-container:
    name: Build container
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Login to container registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GHCR_PAT }}
      - name: Set up docker buildx
        uses: docker/setup-buildx-action@v2
      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          context: .
          load: true
          tags: edge-proxy:latest-openresty
      - name: Debug
        run: docker images

  locations-rules:
    name: Test location rules
    runs-on: ubuntu-latest

    needs:
      - build-container

    services:
      #edge-proxy:
      #  image: edge-proxy:latest-openresty
      #  ports:
      #    - 80:80
      #  options: >-
      #    --env-file scripts/local.env
      idp:
        image: traefik/whoami
        options: >-
          -e WHOAMI_PORT_NUMBER=8080
          -e WHOAMI_NAME=idp
      ocs-proxy:
        image: traefik/whoami
        options: >-
          -e WHOAMI_PORT_NUMBER=8080
          -e WHOAMI_NAME=ocs-proxy
      fr-stunnel:
        image: traefik/whoami
        options: >-
          -e WHOAMI_PORT_NUMBER=8080
          -e WHOAMI_NAME=fr-stunnel          

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Debug
        run: docker images
      - name: Install python
        uses: actions/setup-python@v4
        with:
          python-version: 3.9
          cache: pip
          cache-dependency-path: tests
      - name: Run tests
        run: behave tests
Moritz Schmitz v. Hülst
  • 3,229
  • 4
  • 36
  • 63

0 Answers0