validator and workflow to test GH actions permissions #1
Workflow file for this run
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
name: Cleanup PR Images | |
on: | |
pull_request: | |
types: [closed] | |
env: | |
# github.repository as <account>/<repo>/<image_name> | |
# github.repository will need to be split to get the correct image name | |
# so we must drop the "GITHUB_REPOSITORY_OWNER/" prefex | |
IMAGE_NAME: ${{ github.repository }}/cloudzero-agent-validator | |
jobs: | |
purge-image: | |
name: Delete image from ghcr.io | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: drop owner from IMAGE_NAME name for delete | |
run: | | |
# trim off the "GITHUB_REPOSITORY_OWNER/" prefix | |
IMAGE_NAME=${IMAGE_NAME#*/} | |
echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV} | |
- name: Delete image | |
uses: bots-house/[email protected] | |
with: | |
owner: cloudzero | |
name: ${{ env.IMAGE_NAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: pr-${{github.event.pull_request.number}} |