-
-
Notifications
You must be signed in to change notification settings - Fork 165
65 lines (55 loc) · 2.2 KB
/
docker.yml
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
name: Docker Build and Test
on:
push:
branches:
- "master"
pull_request:
branches:
- "master"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Build and push: If this is a push to master, tag as 'latest'
- name: Build and push (production)
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:latest
# Build and push: If this is a pull request, push to a 'test' tag
- name: Build and push (test)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:test
# Pull and test the production image (only for master branch pushes)
- name: Pull the image from Docker Hub (production)
if: github.ref == 'refs/heads/master'
run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:latest
- name: Test Docker Image (production)
if: github.ref == 'refs/heads/master'
run: docker run --rm ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:latest "deep learning" --nresults 20
# Pull and test the test image (only for PRs)
- name: Pull the image from Docker Hub (test)
if: github.event_name == 'pull_request'
run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:test
- name: Test Docker Image (test)
if: github.event_name == 'pull_request'
run: docker run --rm ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:test "deep learning" --nresults 10