Clement Vachet commited on
Commit
49da0d6
·
1 Parent(s): c8fa85e

Add github action - push docker image

Browse files
.github/workflows/publish_docker_image.yml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+
6
+ # GitHub recommends pinning actions to a commit SHA.
7
+ # To get a newer version, you will need to update the SHA.
8
+ # You can also reference a tag or branch, but the action may change without warning.
9
+
10
+ name: Publish Docker image
11
+
12
+ on:
13
+ push:
14
+ branches: [ 'main' ]
15
+ workflow_dispatch:
16
+
17
+ jobs:
18
+ push_to_registry:
19
+ name: Push Docker image to Docker Hub
20
+ runs-on: ubuntu-latest
21
+ permissions:
22
+ packages: write
23
+ contents: read
24
+ attestations: write
25
+ id-token: write
26
+ steps:
27
+ - name: Check out the repo
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Set up Python
31
+ uses: actions/setup-python@v4
32
+ with:
33
+ python-version: '3.11'
34
+
35
+ - name: Install dependencies
36
+ run: |
37
+ python -m pip install --upgrade pip
38
+ pip install -r requirements.txt
39
+
40
+ - name: Run tests
41
+ id: pytest
42
+ run: pytest
43
+
44
+ - name: Log in to Docker Hub
45
+ if: steps.pytest.outcome == 'success'
46
+ uses: docker/login-action@v3
47
+ with:
48
+ username: ${{ secrets.DOCKER_USERNAME }}
49
+ password: ${{ secrets.DOCKER_TOKEN }}
50
+
51
+ - name: Extract metadata (tags, labels) for Docker
52
+ id: meta
53
+ uses: docker/metadata-action@v5
54
+ with:
55
+ images: cvachet/object-detection-lambda
56
+
57
+ - name: Build and push Docker image
58
+ id: push
59
+ uses: docker/build-push-action@v6
60
+ with:
61
+ context: .
62
+ file: ./Dockerfile
63
+ push: true
64
+ tags: cvachet/object-detection-lambda:latest
65
+ # tags: ${{ steps.meta.outputs.tags }}
66
+ # labels: ${{ steps.meta.outputs.labels }}