-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from unicef/release/0.1
Release/0.1
- Loading branch information
Showing
171 changed files
with
7,852 additions
and
1,725 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action | ||
name: 'Delete Docker Image' | ||
description: 'Delete Docker Image from Registry' | ||
inputs: | ||
image: | ||
description: 'Image name to delete' | ||
required: true | ||
tag: | ||
description: 'Tag to delete' | ||
required: true | ||
username: | ||
description: 'Docker Username' | ||
required: true | ||
password: | ||
description: 'Docker Password' | ||
required: true | ||
registry: | ||
description: 'Files to use to calculate the hash' | ||
required: false | ||
default: "https://hub.docker.com/v2" | ||
|
||
|
||
outputs: | ||
checksum: # id of output | ||
description: 'The time we greeted you' | ||
value: ${{ steps.calc.outputs.checksum }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- id: calc | ||
shell: bash | ||
run: | | ||
registry=${{ inputs.registry }} | ||
name=${{ inputs.image }} | ||
tag=${{ inputs.tag }} | ||
echo "::notice:: 111111111 Deleting Image ${name}:${tag}" | ||
TOKEN=$(\ | ||
curl \ | ||
--silent \ | ||
--header "Content-Type: application/json" \ | ||
--request POST \ | ||
--data '{"username": "'${{ inputs.username }}'", "password": "'${{ inputs.password }}'" }' \ | ||
${registry}/users/login/ \ | ||
| jq -r .token\ | ||
) | ||
curl -X DELETE \ | ||
--header "Authorization: JWT ${TOKEN}" \ | ||
--header "Accept: application/json" \ | ||
${registry}/repositories/${name}/tags/${tag} | ||
# echo "::notice:: curl $auth -sI -k \ | ||
# -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' \ | ||
# https://${registry}/v2/${name}/manifests/${tag}" | ||
# | ||
# echo "::notice:: 111111111 $auth" | ||
# | ||
# digest=$(curl $auth -sI -k \ | ||
# -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ | ||
# "https://${registry}/v2/${name}/manifests/${tag}") | ||
# echo "::notice:: 111111111 ${digest}" | ||
# | ||
# curl $auth -X DELETE -sI -k "https://${registry}/v2/${name}/manifests/$( | ||
# curl $auth -sI -k \ | ||
# -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ | ||
# "https://${registry}/v2/${name}/manifests/${tag}" \ | ||
# | tr -d '\r' | sed -En 's/^Docker-Content-Digest: (.*)/\1/pi' | ||
# )" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,30 @@ | ||
name: Branch Deleted | ||
name: Delete Outdated Docker Image | ||
on: delete | ||
jobs: | ||
delete: | ||
if: github.event.ref_type == 'branch' | ||
delete_branch: | ||
if: github.event.ref_type == 'branch' || github.event.ref_type == 'tag' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
|
||
- name: Delete Test Docker Image | ||
shell: bash | ||
run: | | ||
name="${{vars.DOCKER_IMAGE}}:test-${{steps.meta.outputs.version}}" | ||
registry="https://registry-1.docker.io" | ||
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$( | ||
curl -sSL -I \ | ||
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ | ||
"http://${registry}/v2/${name}/manifests/$( | ||
curl -sSL "http://${registry}/v2/${name}/tags/list" | jq -r '.tags[0]' | ||
)" \ | ||
| awk '$1 == "Docker-Content-Digest:" { print $2 }' \ | ||
| tr -d $'\r' \ | ||
)" | ||
- name: Delete linked Docker Image | ||
shell: bash | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
- shell: bash | ||
run: | | ||
name="${{vars.DOCKER_IMAGE}}:${{steps.meta.outputs.version}}" | ||
registry="https://registry-1.docker.io" | ||
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$( | ||
curl -sSL -I \ | ||
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ | ||
"http://${registry}/v2/${name}/manifests/$( | ||
curl -sSL "http://${registry}/v2/${name}/tags/list" | jq -r '.tags[0]' | ||
)" \ | ||
| awk '$1 == "Docker-Content-Digest:" { print $2 }' \ | ||
| tr -d $'\r' \ | ||
)" | ||
ref="${{github.ref}}" | ||
tag=$(echo $ref | sed -e "s#refs/heads/##g" | sed -e s#/#-##g) | ||
echo "ref=$ref" >> $GITHUB_ENV | ||
echo "dist_tag=$tag" >> $GITHUB_ENV | ||
echo "test_tag=test-${tag}" >> $GITHUB_ENV | ||
- uses: ./.github/actions/delete_docker | ||
if: github.event.ref_type == 'tag' | ||
with: | ||
image: ${{vars.DOCKER_IMAGE}} | ||
tag: ${{ env.dist_tag }} | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- uses: ./.github/actions/delete_docker | ||
with: | ||
image: ${{vars.DOCKER_IMAGE}} | ||
tag: ${{ env.test_tag }} | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.