File tree Expand file tree Collapse file tree 2 files changed +28
-35
lines changed
Expand file tree Collapse file tree 2 files changed +28
-35
lines changed Original file line number Diff line number Diff line change 8787 ``` bash
8888 docker pull ghcr.io/the-strategy-unit/nhp_model:pr-${{ github.event.number }}
8989 ```
90-
91- [Download Artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
9290 edit-mode : replace
9391
9492 deploy-ghcr :
@@ -163,4 +161,31 @@ jobs:
163161 if : ${{ inputs.latest }}
164162 run : |
165163 docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
166- docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
164+ docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
165+
166+ remove-pr-image :
167+ runs-on : ubuntu-latest
168+ needs : ["deploy-ghcr"]
169+ if : github.event_name == 'pull_request' && github.event.action == 'closed'
170+ permissions :
171+ packages : write
172+ contents : read
173+ steps :
174+ - name : " Remove pr image"
175+ env :
176+ TAG_TO_DELETE : " pr-${{ github.event.pull_request.number }}"
177+ run : |
178+ VERSION_ID=$(gh api /orgs/the-strategy-unit/packages/container/nhp_model/versions \
179+ -H "Accept: application/vnd.github+json" \
180+ --paginate | \
181+ jq -r '.[] | select(.metadata.container.tags[] == "$TAG_TO_DELETE") | .id')
182+
183+ if [ -n "$VERSION_ID" ]; then
184+ echo "Deleting version ID: $VERSION_ID"
185+ gh api \
186+ -X DELETE \
187+ /orgs/the-strategy-unit/packages/container/nhp_model/versions/${VERSION_ID} \
188+ -H "Accept: application/vnd.github+json"
189+ else
190+ echo "Tag '$TAG_TO_DELETE' not found — skipping delete"
191+ fi
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments