-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mriyam Tamuli <[email protected]>
- Loading branch information
Showing
4 changed files
with
94 additions
and
39 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Create and publish the container image. | ||
|
||
on: | ||
push: | ||
branches: | ||
tags: | ||
|
||
env: | ||
BASE_REPOSITORY: warmmetal/csi-driver-image | ||
BASE_DEFAULT_BRANCH: master | ||
BASE_IMAGE_NAME: warmmetal/csi-image | ||
FORK_IMAGE_NAME: ghcr.io/${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
if: github.repository == env.BASE_REPOSITORY | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Log in to the GitHub Container registry | ||
uses: docker/login-action@v3 | ||
if: github.repository != env.BASE_REPOSITORY | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
name=${{ env.BASE_IMAGE_NAME }},enable=${{ github.repository == env.BASE_REPOSITORY }} | ||
name=${{ env.FORK_IMAGE_NAME }},enable=${{ github.repository != env.BASE_REPOSITORY }} | ||
tags: | | ||
# set 'latest' tag for default branch | ||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', env.BASE_DEFAULT_BRANCH) }} | ||
# set image tag based on GitHub release tag | ||
type=semver,pattern={{version}},prefix=v | ||
# set the image tag based on the branch | ||
# https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 | ||
type=ref,event=branch,enable=${{ github.ref_name != env.BASE_DEFAULT_BRANCH }} | ||
flavor: | | ||
latest=false | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Delete old container images | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" # Source: https://crontab.guru/every-day | ||
|
||
permissions: | ||
packages: write | ||
|
||
env: | ||
BASE_REPOSITORY: warmmetal/csi-driver-image | ||
|
||
jobs: | ||
clean-ghcr: | ||
name: Delete old unused container images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/delete-package-versions@v4 | ||
if: github.repository != env.BASE_REPOSITORY | ||
with: | ||
owner: ${{ github.repository_owner }} | ||
package-name: ${{ github.event.repository.name }} | ||
package-type: 'container' | ||
min-versions-to-keep: 1 | ||
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string | ||
# Ignore any semver or 'latest' | ||
ignore-versions: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?|latest$' |
This file was deleted.
Oops, something went wrong.