HyukjinKwon commented on code in PR #37005:
URL: https://github.com/apache/spark/pull/37005#discussion_r916365875


##########
.github/workflows/build_and_test.yml:
##########
@@ -805,3 +865,29 @@ jobs:
       with:
         name: unit-tests-log-docker-integration--8-${{ inputs.hadoop }}-hive2.3
         path: "**/target/unit-tests.log"
+
+  # Note that: there are only GHCR creation permission for secrets.GITHUB_TOKEN
+  # If you want to clean up the CI images, you need to:
+  # - 1. Generate the token from https://github.com/settings/tokens with 
`write:packages` and `delete:packages`
+  # - 2. Add the the token as secrets `GHCR_DEL` in 
https://github.com/{username}}/spark/settings/secrets/actions
+  infra-image-post:
+    # Always runs after pyspark have completed, regardless of whether they 
were successful
+    if: always()
+    needs: [infra-image, pyspark]
+    runs-on: ubuntu-20.04
+    # Secrets cannot be used by if condition, so add env in here
+    # See also: https://github.com/actions/runner/issues/1138
+    env:
+      GHCR_DEL: ${{ secrets.GHCR_DEL }}
+    steps:
+    - name: Cleanup docker image
+      # Only cleanup the ci images when users set the secrets in fork repo
+      if: ${{ env.GHCR_DEL }} && ${{ inputs.branch }} == 'master'
+      # TODO: Switch to actions/delete-package-versions when it is supported:
+      # https://github.com/actions/delete-package-versions/issues/74
+      run: >
+        curl
+        -X DELETE
+        -H "Accept: application/vnd.github+json"
+        -H "Authorization: token ${{ secrets.GHCR_DEL }}"
+        https://api.github.com/user/packages/container/${{ 
needs.infra-image.outputs.image_name }}

Review Comment:
   Thanks for explanation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to