Skip to content

Commit

Permalink
deleting old containers after pushing to dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndeta100 committed Jan 16, 2024
1 parent afc3e4b commit c9d6b0b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/dockerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push to docker hub

- name: Build and push to Docker Hub
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ndeta100/hotel-api:${{ github.run_number }}
- name: Clean up
run: docker rmi ndeta100/hotel-api:${{ github.run_number -1}}
tags: ndeta100/hotel-api:latest
ndeta100/hotel-api:${{ github.sha }}

- name: Delete old containers
uses: snok/[email protected]
with:
image-names: "ndeta100/hotel-api"
cut-off: A week ago UTC
account-type: org
org-name: ndeta100
keep-at-least: 3
skip-tags: latest, v*
token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

0 comments on commit c9d6b0b

Please sign in to comment.