Skip to content

Commit

Permalink
Ci: GHCR Purge success even if package doesn't exist (#3504)
Browse files Browse the repository at this point in the history
* ci: workflow run on ci branch for debuging

* Run CI with PR sources (#3479)

* Run CI with PR sources

* Add CI branch to the pull_request_target

---------

Co-authored-by: Julien <julien@citio.digital>

* GHCR Purge success even if package doesn't exist (#3480)

* GHCR Purge success even if package doesn't exist

* Add CI branch to pull_request_target

* typo

---------

Co-authored-by: Julien <julien@citio.digital>

* Update VERSION to test CI (#3481)

---------

Co-authored-by: jlestel <jlestel@gmail.com>
Co-authored-by: Julien <julien@citio.digital>
  • Loading branch information
3 people committed Feb 9, 2024
1 parent 33db90a commit 3308e52
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/ghcr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ on:
paths:
- "**/*"
- "!.github/**"
branches: ["ci"]
pull_request_target:
branches: ["master"]
branches: ["master", "ci"]
paths:
- "**/*"
- "!.github/**" # Important: Exclude PRs related to .github from auto-run
Expand Down Expand Up @@ -39,8 +40,14 @@ jobs:
runs-on: ${{ matrix.runs_on }}
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Buildx
uses: ./.github/actions/build
with:
Expand Down Expand Up @@ -76,8 +83,13 @@ jobs:
grafana:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3.0.0
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ghcr_purge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ permissions:
packages: write

jobs:
purge-pr-untagged:
name: Delete untagged images from ghcr.io
purge-pr-package:
name: Delete images from ghcr.io when PR is closed
runs-on: ubuntu-latest

steps:
- uses: chipkent/action-cleanup-package@v1.0.1
id: cleanup
continue-on-error: true
with:
package-name: ${{ github.event.repository.name }}
tag: pr-${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/delete-package-versions@v4
if: job.steps.cleanup.status == success()
name: Delete untagged images from ghcr.io
continue-on-error: true
with:
package-name: "teslamate"
package-type: "container"
min-versions-to-keep: 0
delete-only-untagged-versions: "true"
token: ${{ secrets.GITHUB_TOKEN }}

purge-pr-package:
name: Delete image from ghcr.io
runs-on: ubuntu-latest

steps:
- uses: chipkent/action-cleanup-package@v1.0.1
with:
package-name: ${{ github.event.repository.name }}
tag: pr-${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.28.2-dev
1.28.2-dev

0 comments on commit 3308e52

Please sign in to comment.