Skip to content
Merged
Show file tree
Hide file tree
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
55 changes: 45 additions & 10 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,68 @@ jobs:
large-packages: true
docker-images: false
swap-storage: true

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v5.0.0

- name: Set up Buildx
uses: docker/setup-buildx-action@v3.11.1

# ----- PR and non-main branch steps -----
# For PRs: Build image but do not push and run smoke tests
- name: Build Docker Image (No Push)
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main')
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6.18.0
with:
context: .
file: ./Dockerfile
push: false
load: true
tags: arc:test
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run Smoke Tests
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main')
run: |
docker run --rm arc:test bash -lc \
"cd /home/mambauser/Code/ARC && micromamba run -n arc_env pytest dockerfiles/docker_tests/test_docker_smoke.py -m smoke -q"

# ----- Main branch only steps -----
# For pushes to main: Build, run smoke tests, and push to Docker Hub
- name: Build test stage (main)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6.18.0
with:
context: .
file: ./Dockerfile
load: true
tags: arc:final-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run smoke (main, test stage)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
docker run --rm arc:final-${{ github.sha }} bash -lc \
"cd /home/mambauser/Code/ARC && micromamba run -n arc_env pytest dockerfiles/docker_tests/test_docker_smoke.py -m smoke -q"

- name: Login to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.5.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3.0.0

- name: Build and Push Docker Image
- name: Build final and push (main)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6.18.0
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/arc:latest
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/arc:latest
${{ secrets.DOCKERHUB_USERNAME }}/arc:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
Loading
Loading