diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index ff42b5088..69fb9c22a 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -3,35 +3,48 @@ name: Test Docker Image # TODO: set docker auth on: workflow_dispatch: -# on: -# push: -# tags: -# - "v*" - -env: - IMAGE: nemoguardrails - TEST_TAG: ${{ env.IMAGE }}:test - LATEST_TAG: ${{ env.IMAGE }}:latest + schedule: + - cron: "0 0 * * 0" + push: + tags: + - "v*" + pull_request: + paths: + - "Dockerfile" + - "pyproject.toml" + - "poetry.lock" + - ".github/workflows/test-docker.yml" jobs: docker: runs-on: ubuntu-latest + env: + IMAGE: nemoguardrails steps: # # Checkout the code - name: Checkout uses: actions/checkout@v4 - # Extract the tag version and set Docker tags - - name: Get git tag and set Docker tags + # Get runner architecture + - name: Get runner architecture + id: runner-arch + run: echo "arch=$(uname -m)" >> $GITHUB_OUTPUT + + - name: Set Docker tags run: | - VERSION=${GITHUB_REF#refs/tags/v} - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "VERSION_TAG=${{ env.IMAGE }}:$VERSION" >> $GITHUB_ENV + ARCH=${{ steps.runner-arch.outputs.arch }} + echo "TEST_TAG=${{ env.IMAGE }}:${{ github.sha }}-$ARCH" >> $GITHUB_ENV - # Build the Docker image - - name: Build the Docker image - run: docker build . --file Dockerfile --tag ${{ env.TEST_TAG }} --tag ${{ env.VERSION_TAG }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build image + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + load: true + tags: ${{ env.TEST_TAG }} # Start the container in detached mode - name: Start container