Skip to content

Commit

Permalink
Merge pull request #1168 from opentensor/sam-make-docker-better
Browse files Browse the repository at this point in the history
make docker image builds trigger on key branches + ability to manually trigger
  • Loading branch information
unconst authored Jan 21, 2025
2 parents c4ea8a4 + fc95d74 commit a99d4c7
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
branch-or-tag:
description: "Branch or tag to use for the Docker image tag and ref to checkout (optional)"
required: false
default: ""

push:
branches:
- devnet-ready
- devnet
- testnet

permissions:
contents: read
Expand All @@ -16,8 +27,18 @@ jobs:
runs-on: SubtensorCI

steps:
- name: Determine Docker tag and ref
id: tag
run: |
branch_or_tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
echo "Determined branch or tag: $branch_or_tag"
echo "tag=$branch_or_tag" >> $GITHUB_ENV
echo "ref=$branch_or_tag" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.ref }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -32,18 +53,10 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/${{ github.repository }}:latest
labels: ${{ steps.meta.outputs.labels }}
ghcr.io/${{ github.repository }}:${{ env.tag }}

0 comments on commit a99d4c7

Please sign in to comment.