Yikun commented on code in PR #37005:
URL: https://github.com/apache/spark/pull/37005#discussion_r915791035
##########
.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:
I think this way is a little bit and complex
- a little bit [flaky
](https://github.com/Yikun/spark/runs/7232613090?check_suite_focus=true#step:2:13)
- also bring some configure complex for developer, we have to add [PAT
secrets rather than
GITHUB_TOKEN](https://github.community/t/github-token-has-no-access-to-new-container-rest-apis/170395)
- also it's not supported well by
[actions/delete-package-versions](https://github.com/actions/delete-package-versions/issues/74)
- also github didn't provide delete [package by
tag](https://docs.github.com/en/rest/packages#delete-a-package-for-a-user) API.
- there are some [3rd party
action](https://github.community/t/delete-image-tag-from-github-container-registry/158852/7)
supported but apache infra will say no.
-
So, I think `apache-spark-ci-image:${{ inputs.branch }}-${{ github.run_id
}}` ([diff tag for each
pr](https://user-images.githubusercontent.com/1736354/177767218-100e59f2-5ab1-4980-a350-a5f809b9ff62.png))
**without any cleanup** better than `apache-spark-ci-image-${{ inputs.branch
}}-${{ github.run_id }}` ([diff packages for each
pr](https://user-images.githubusercontent.com/1736354/177767350-56a2fbcb-963f-4925-86ea-0abf45ccbc68.png))
by auto deletion.
If developers want to delete package for some reason, they can also delete
complete image in github page.
@HyukjinKwon So, I decided to remove `infra-image-post` (image cleanup job).
WDYT?
--
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]