diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 589ed0191..7687465b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,4 +34,15 @@ jobs: secrets: inherit with: artifact: issuer-api - tag: "waltid/issuer-api:${{ needs.version.outputs.release_version }}" \ No newline at end of file + tag: "waltid/issuer-api:${{ needs.version.outputs.release_version }}" + artifact-names: + uses: walt-id/waltid-identity/.github/workflows/map.yml@feat/docker-build-share + needs: [ docker-matrix ] + with: + json: ${{ needs.docker-matrix.outputs.json }} + property: image + cleanup: + uses: walt-id/waltid-identity/.github/workflows/cleanup.yml@feat/docker-build-share + needs: [ artifact-names, ebsi-ct-v3 ] + with: + artifacts: ${{ needs.artifact-names.outputs.list }} \ No newline at end of file diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 000000000..9401fe7fe --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,38 @@ +name: Delete Artifacts + +on: + workflow_call: + inputs: + artifacts: + required: true + type: string + +jobs: + delete: + runs-on: ubuntu-latest + strategy: + matrix: + artifact: ${{ inputs.artifacts }} + steps: + - name: Delete artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + artifact_name="${{ matrix.artifact }}" + echo "Deleting artifact: $artifact_name" + + # Get the artifact ID for the known artifact name + ARTIFACT_ID=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/actions/artifacts" | \ + jq -r ".artifacts[] | select(.name == \"$artifact_name\") | .id") + + # Delete the artifact if found + if [ -n "$ARTIFACT_ID" ]; then + curl -X DELETE \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$ARTIFACT_ID" + echo "Artifact '$artifact_name' deleted." + else + echo "No artifact named '$artifact_name' found to delete." + fi \ No newline at end of file diff --git a/.github/workflows/map.yml b/.github/workflows/map.yml new file mode 100644 index 000000000..f5a40df2e --- /dev/null +++ b/.github/workflows/map.yml @@ -0,0 +1,34 @@ +name: Load json + +on: + workflow_call: + inputs: + json: + description: "the json file path containing the matrix" + required: true + type: string + property: + description: "the property to map to" + required: true + type: string + outputs: + list: + description: "The list of values" + value: ${{ jobs.map.outputs.list }} + +jobs: + map: + runs-on: ubuntu-latest + outputs: + list: ${{ steps.list.outputs.list }} + steps: + - name: Extract names from JSON + id: list + run: | + # Define the JSON input + json_data=${{ inputs.json }} + echo "$json_data" + # Use jq to extract names into a list + names=$(echo $json_data | jq -r 'map(.image) | @csv' | tr -d '"') + # Set the output as an environment variable + echo "list=$names" >> $GITHUB_OUTPUT \ No newline at end of file