Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/docker-publish-pytorch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "PyTorch" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "PyTorch" ]

env:
REGISTRY:
IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_REPO }}

jobs:
build_latest:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@main

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image (without tag for pull request)
if: github.event_name == 'pull_request'
run: docker build -f Dockerfile .

- name: Build image
if: github.event_name == 'push' && github.ref == 'refs/heads/PyTorch'
run: docker build -f Dockerfile --tag ${IMAGE_NAME}:pytorch .

- name: Login to Dockerhub container registry
if: github.event_name == 'push' && github.ref == 'refs/heads/PyTorch'
run: docker login -u ${{ vars.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push image
if: github.event_name == 'push' && github.ref == 'refs/heads/PyTorch'
run: docker push ${IMAGE_NAME}:pytorch

build_release:
# Build an extra image for tagged commits
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@main

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
run: docker build -f Dockerfile --tag ${IMAGE_NAME}:${{ github.ref_name }} .

- name: Login to Dockerhub container registry
run: docker login -u ${{ vars.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push image
run: docker push ${IMAGE_NAME}:${{ github.ref_name }}
Loading