Merge pull request #910 from wildmeshing/dzint/image_simulation #166
This file contains hidden or 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: Build and Push Docker Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-push-standard: | |
| if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| docker-images: false | |
| swap-storage: false | |
| - name: Log in to DockerHub | |
| if: github.event_name == 'push' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Cache Docker layers | |
| uses: actions/cache@v3 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: docker-${{ runner.os }}-${{ github.sha }} | |
| restore-keys: docker-${{ runner.os }}- | |
| - name: Build and Push Standard Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| # Push only on push to main, not PRs | |
| push: ${{ github.event_name == 'push' }} | |
| # Load into Docker engine for PRs so tests can run | |
| load: ${{ github.event_name == 'pull_request' }} | |
| tags: | | |
| ${{ secrets.DOCKER_USERNAME }}/wmtk:latest | |
| ${{ secrets.DOCKER_USERNAME }}/wmtk:${{ github.sha }} | |
| cache-from: type=local,src=/tmp/.buildx-cache | |
| cache-to: type=local,dest=/tmp/.buildx-cache,mode=max | |
| platforms: linux/amd64 | |
| - name: Test Standard Docker Image (PR local) | |
| if: github.event_name == 'pull_request' | |
| run: docker run --rm ${{ secrets.DOCKER_USERNAME }}/wmtk:latest --help | |
| - name: Test Standard Docker Image (pushed) | |
| if: github.event_name == 'push' | |
| run: docker run --rm ${{ secrets.DOCKER_USERNAME }}/wmtk:latest --help |