-
Notifications
You must be signed in to change notification settings - Fork 24
99 lines (89 loc) · 3.27 KB
/
docker_build.yml
File metadata and controls
99 lines (89 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Docker Image Build and Push
on:
schedule:
- cron: "0 0 */7 * *" # every 7 days
push:
branches:
- main
paths:
- "Dockerfile"
- ".github/workflows/docker_build.yml"
pull_request:
branches:
- main
paths:
- "Dockerfile"
- ".github/workflows/docker_build.yml"
types: [opened, synchronize, reopened, ready_for_review]
#workflow_dispatch: # Add this line to enable manual trigger
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: true
- name: Checkout
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@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.5.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build final and push (main)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6.18.0
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/arc:latest
${{ secrets.DOCKERHUB_USERNAME }}/arc:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max