Skip to content

Commit

Permalink
conditionally delete imgs
Browse files Browse the repository at this point in the history
  • Loading branch information
AyodeAwe committed Aug 1, 2023
1 parent ca25c87 commit b6e85f9
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 31 deletions.
28 changes: 28 additions & 0 deletions .github/actions/compute-matrix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Compute Matrix Action'
description: 'Computes matrix'
outputs:
MATRIX:
description: "Computed matrix"
value: ${{ steps.compute-matrix.outputs.MATRIX }}
LATEST_LINUX_VER:
description: "Latest Linux version"
value: ${{ steps.latest-values.outputs.LATEST_LINUX_VER }}
LATEST_CUDA_VER:
description: "Latest CUDA version"
value: ${{ steps.latest-values.outputs.LATEST_CUDA_VER }}
LATEST_PYTHON_VER:
description: "Latest Python version"
value: ${{ steps.latest-values.outputs.LATEST_PYTHON_VER }}
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Compute latest values
id: latest-values
run: ./ci/compute-latest-versions.sh
- name: Compute matrix
id: compute-matrix
run: |
MATRIX=$(ci/compute-mx.sh)
echo "MATRIX=${MATRIX}" | tee -a ${GITHUB_OUTPUT}
43 changes: 12 additions & 31 deletions .github/workflows/build-and-publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,15 @@ jobs:
runs-on: ubuntu-latest
outputs:
MATRIX: ${{ steps.compute-matrix.outputs.MATRIX }}
LATEST_LINUX_VER: ${{ steps.latest-values.outputs.LATEST_LINUX_VER }}
LATEST_CUDA_VER: ${{ steps.latest-values.outputs.LATEST_CUDA_VER }}
LATEST_PYTHON_VER: ${{ steps.latest-values.outputs.LATEST_PYTHON_VER }}
LATEST_LINUX_VER: ${{ steps.compute-matrix.outputs.LATEST_LINUX_VER }}
LATEST_CUDA_VER: ${{ steps.compute-matrix.outputs.LATEST_CUDA_VER }}
LATEST_PYTHON_VER: ${{ steps.compute-matrix.outputs.LATEST_PYTHON_VER }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Compute latest values
id: latest-values
run: ./ci/compute-latest-versions.sh
- name: Compute matrix
- name: Compute Matrix
id: compute-matrix
run: |
MATRIX=$(ci/compute-mx.sh)
echo "MATRIX=${MATRIX}" | tee -a ${GITHUB_OUTPUT}
uses: ./.github/actions/compute-matrix
docker:
needs: compute-matrix
strategy:
Expand Down Expand Up @@ -81,24 +76,10 @@ jobs:
needs: [compute-matrix, build-multiarch-manifest]
strategy:
matrix: ${{ fromJSON(needs.compute-matrix.outputs.MATRIX) }}
runs-on: ubuntu-latest
steps:
- name: Remove temporary images
run: |
HUB_TOKEN=$(
curl -s -H "Content-Type: application/json" \
-X POST \
-d "{\"username\": \"${{ secrets.GPUCIBOT_DOCKERHUB_USER }}\", \"password\": \"${{ secrets.GPUCIBOT_DOCKERHUB_TOKEN }}\"}" \
https://hub.docker.com/v2/users/login/ | jq -r .token \
)
org="rapidsai"
repo="ci"
tag="cuda${{ matrix.CUDA_VER }}-${{ matrix.LINUX_VER }}-py${{ matrix.PYTHON_VER }}"
for arch in $(echo '${{ toJSON(matrix.ARCHES) }}' | jq .[] -r); do
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT $HUB_TOKEN" \
"https://hub.docker.com/v2/repositories/$org/$repo/tags/$tag-$arch/"
done
fail-fast: false
uses: ./.github/workflows/delete-temp-images.yml
with:
ARCHES: ${{ toJSON(matrix.ARCHES) }}
CUDA_VER: ${{ matrix.CUDA_VER }}
LINUX_VER: ${{ matrix.LINUX_VER }}
PYTHON_VER: ${{ matrix.PYTHON_VER }}
42 changes: 42 additions & 0 deletions .github/workflows/delete-temp-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Delete temporary images

on:
workflow_call:
inputs:
CUDA_VER:
required: true
type: string
LINUX_VER:
required: true
type: string
PYTHON_VER:
required: true
type: string
ARCHES:
required: true
type: string

jobs:
delete-temp-images:
runs-on: ubuntu-latest
if: always()
steps:
- name: Remove temporary images
run: |
HUB_TOKEN=$(
curl -s -H "Content-Type: application/json" \
-X POST \
-d "{\"username\": \"${{ secrets.GPUCIBOT_DOCKERHUB_USER }}\", \"password\": \"${{ secrets.GPUCIBOT_DOCKERHUB_TOKEN }}\"}" \
https://hub.docker.com/v2/users/login/ | jq -r .token \
)
org="rapidsai"
repo="ci"
tag="cuda${{ inputs.CUDA_VER }}-${{ inputs.LINUX_VER }}-py${{ inputs.PYTHON_VER }}"
for arch in $(echo '${{ inputs.ARCHES }}' | jq .[] -r); do
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT $HUB_TOKEN" \
"https://hub.docker.com/v2/repositories/$org/$repo/tags/$tag-$arch/"
done
25 changes: 25 additions & 0 deletions .github/workflows/pr-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
pull_request:
types: [closed]

jobs:
compute-matrix:
runs-on: ubuntu-latest
outputs:
MATRIX: ${{ steps.compute-matrix.outputs.MATRIX }}
steps:
- uses: actions/checkout@v3
- name: Compute Matrix Action
id: compute-matrix
uses: ./.github/actions/compute-matrix
delete-imgs:
needs: compute-matrix
strategy:
matrix: ${{ fromJSON(needs.compute-matrix.outputs.MATRIX) }}
uses: ./.github/workflows/delete-temp-images.yml
with:
ARCHES: ${{ toJSON(matrix.ARCHES) }}
CUDA_VER: ${{ matrix.CUDA_VER }}
LINUX_VER: ${{ matrix.LINUX_VER }}
PYTHON_VER: ${{ matrix.PYTHON_VER }}

0 comments on commit b6e85f9

Please sign in to comment.