Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down