FIX #49: Docker setup and instructions (#50) #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |