From 5ff711dd9a83d2760f64bff2059e9c847d565794 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 17 Jan 2025 15:12:18 -0500 Subject: [PATCH 1/4] make docker image builds trigger on key branches --- .github/workflows/docker.yml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fd00e9a31..4ace8c6fe 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,11 @@ on: release: types: [published] workflow_dispatch: + push: + branches: + - devnet-ready + - devnet + - testnet permissions: contents: read @@ -32,11 +37,24 @@ 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: Determine Docker tag + id: tag + run: | + case "${{ github.ref_name }}" in + devnet-ready) + echo "tag=devnet-ready" >> $GITHUB_ENV + ;; + devnet) + echo "tag=devnet" >> $GITHUB_ENV + ;; + testnet) + echo "tag=testnet" >> $GITHUB_ENV + ;; + *) + echo "Branch not recognized for custom tagging." + exit 1 + ;; + esac - name: Build and push Docker image uses: docker/build-push-action@v4 @@ -44,6 +62,5 @@ jobs: context: . push: true tags: | - ${{ steps.meta.outputs.tags }} + ghcr.io/${{ github.repository }}:${{ env.tag }} ghcr.io/${{ github.repository }}:latest - labels: ${{ steps.meta.outputs.labels }} From 18a4c6de7e264427ce75ed36201fc122186bdbc8 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 17 Jan 2025 15:58:10 -0500 Subject: [PATCH 2/4] fix --- .github/workflows/docker.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4ace8c6fe..fa15d8174 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,12 @@ on: release: types: [published] workflow_dispatch: + inputs: + branch-or-tag: + description: "Branch or tag to use for the Docker image tag (optional)" + required: false + default: "" + push: branches: - devnet-ready @@ -40,21 +46,10 @@ jobs: - name: Determine Docker tag id: tag run: | - case "${{ github.ref_name }}" in - devnet-ready) - echo "tag=devnet-ready" >> $GITHUB_ENV - ;; - devnet) - echo "tag=devnet" >> $GITHUB_ENV - ;; - testnet) - echo "tag=testnet" >> $GITHUB_ENV - ;; - *) - echo "Branch not recognized for custom tagging." - exit 1 - ;; - esac + # Use the provided branch-or-tag input or fallback to the current ref + 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 - name: Build and push Docker image uses: docker/build-push-action@v4 From 53cdd8f2ed2bea4d45a20724eca7ff2faaacd543 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 17 Jan 2025 16:00:42 -0500 Subject: [PATCH 3/4] use specified ref --- .github/workflows/docker.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fa15d8174..85fd20269 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: branch-or-tag: - description: "Branch or tag to use for the Docker image tag (optional)" + description: "Branch or tag to use for the Docker image tag and ref to checkout (optional)" required: false default: "" @@ -27,8 +27,19 @@ jobs: runs-on: SubtensorCI steps: + - name: Determine Docker tag and ref + id: tag + run: | + # Use the provided branch-or-tag input or fallback to the current ref + 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 @@ -43,14 +54,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Determine Docker tag - id: tag - run: | - # Use the provided branch-or-tag input or fallback to the current ref - 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 - - name: Build and push Docker image uses: docker/build-push-action@v4 with: From fede19b80817315a512ec5a69b86db2198997e5c Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 17 Jan 2025 16:17:26 -0500 Subject: [PATCH 4/4] only bump latest tag if this is a github release! --- .github/workflows/docker.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 85fd20269..530c7cd8d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,7 +30,6 @@ jobs: - name: Determine Docker tag and ref id: tag run: | - # Use the provided branch-or-tag input or fallback to the current ref 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 @@ -61,4 +60,3 @@ jobs: push: true tags: | ghcr.io/${{ github.repository }}:${{ env.tag }} - ghcr.io/${{ github.repository }}:latest