Skip to content

Commit 55a5344

Browse files
authored
ci: enable docker test workflow (#1016)
1 parent 72c8ec0 commit 55a5344

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

.github/workflows/test-docker.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,48 @@ name: Test Docker Image
33
# TODO: set docker auth
44
on:
55
workflow_dispatch:
6-
# on:
7-
# push:
8-
# tags:
9-
# - "v*"
10-
11-
env:
12-
IMAGE: nemoguardrails
13-
TEST_TAG: ${{ env.IMAGE }}:test
14-
LATEST_TAG: ${{ env.IMAGE }}:latest
6+
schedule:
7+
- cron: "0 0 * * 0"
8+
push:
9+
tags:
10+
- "v*"
11+
pull_request:
12+
paths:
13+
- "Dockerfile"
14+
- "pyproject.toml"
15+
- "poetry.lock"
16+
- ".github/workflows/test-docker.yml"
1517

1618
jobs:
1719
docker:
1820
runs-on: ubuntu-latest
21+
env:
22+
IMAGE: nemoguardrails
1923
steps:
2024
#
2125
# Checkout the code
2226
- name: Checkout
2327
uses: actions/checkout@v4
2428

25-
# Extract the tag version and set Docker tags
26-
- name: Get git tag and set Docker tags
29+
# Get runner architecture
30+
- name: Get runner architecture
31+
id: runner-arch
32+
run: echo "arch=$(uname -m)" >> $GITHUB_OUTPUT
33+
34+
- name: Set Docker tags
2735
run: |
28-
VERSION=${GITHUB_REF#refs/tags/v}
29-
echo "VERSION=$VERSION" >> $GITHUB_ENV
30-
echo "VERSION_TAG=${{ env.IMAGE }}:$VERSION" >> $GITHUB_ENV
36+
ARCH=${{ steps.runner-arch.outputs.arch }}
37+
echo "TEST_TAG=${{ env.IMAGE }}:${{ github.sha }}-$ARCH" >> $GITHUB_ENV
3138
32-
# Build the Docker image
33-
- name: Build the Docker image
34-
run: docker build . --file Dockerfile --tag ${{ env.TEST_TAG }} --tag ${{ env.VERSION_TAG }}
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
- name: Build image
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: .
45+
file: Dockerfile
46+
load: true
47+
tags: ${{ env.TEST_TAG }}
3548

3649
# Start the container in detached mode
3750
- name: Start container

0 commit comments

Comments
 (0)