refactor: remove SHA-only Docker tags #9
This file contains hidden or 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: Docker Image CI | |
| on: | |
| push: | |
| branches: | |
| - "feature/docker-containerization" # Only containerization branch for now | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] # Skip draft PRs | |
| branches: | |
| - "develop" | |
| - "main" | |
| - "feature/sn-auth-package-extraimprovements" # Current dev branch with latest sn-auth | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # Skip draft PRs | |
| if: github.event.pull_request.draft == false || github.event_name == 'push' | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v4 | |
| - name: Check if Dockerfile exists | |
| id: check_dockerfile | |
| run: | | |
| if [ -f "Dockerfile" ]; then | |
| echo "dockerfile_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "dockerfile_exists=false" >> $GITHUB_OUTPUT | |
| echo "β οΈ No Dockerfile found, skipping Docker build" | |
| fi | |
| - name: Set up Docker metadata | |
| if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: sensenetcsp/sn-client | |
| tags: | | |
| # Clean branch name (e.g., feature-docker-containerization) | |
| type=ref,event=branch | |
| # Branch name with SHA (e.g., feature-docker-containerization-abc1234) | |
| type=ref,event=branch,suffix=-{{sha}} | |
| # Latest tag for main branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| # PR number for pull requests | |
| type=ref,event=pr | |
| - name: Login to DockerHub | |
| if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |