Skip to content

Commit

Permalink
pointless limitation
Browse files Browse the repository at this point in the history
Signed-off-by: Mriyam Tamuli <[email protected]>
  • Loading branch information
mbtamuli committed Jan 12, 2024
1 parent cb4ccf2 commit c40a2a9
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/images-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: Create and publish the container image.

on:
push:
branches: [master]
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
Expand All @@ -14,21 +20,36 @@ jobs:

- 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: |
warmmetal/csi-image
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={{is_default_branch}}
# 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}}
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
Expand Down

0 comments on commit c40a2a9

Please sign in to comment.