Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only upload images declared in metadata.yaml in the publish workflow #189

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/publish_charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,25 @@ jobs:
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }}
run: |
charmName=$(yq -e '.name' metadata.yaml)
for image in $(cat ${{ env.CHARM_NAME }}-images)
do
charm=$(yq -e '.name' metadata.yaml)
declare -a resources
declare -a images

for resource in $(yq -er '.resources | with_entries(select(.value.type=="oci-image")) | keys | join(" ")' metadata.yaml); do
resources+=("$resource")
done

for image in $(cat ${{ env.CHARM_NAME }}-images); do
images+=("$image")
done

for image in "${images[@]}"; do
docker pull $image
imageId=$(docker images $image --format "{{.ID}}")
charmcraft upload-resource $charmName $(echo $image | awk -F '/' '{print $NF}' | cut -d ':' -f 1)-image --image=$imageId --verbosity=brief
image_id=$(docker images $image --format "{{.ID}}")
resource=$(echo $image | awk -F '/' '{print $NF}' | cut -d ':' -f 1)-image
if [[ " ${resources[@]} " =~ " $resource " ]]; then
charmcraft upload-resource $charm $resource --image=$image_id --verbosity=brief
fi
done
publish-charm:
name: Publish charm to ${{ inputs.channel }}
Expand Down
Loading