Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Docker Image CI

on:
push:
branches:
- 'develop'
- 'main'
- 'master'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- 'develop'
- 'main'
- 'master'
workflow_dispatch:
inputs:
push_image:
description: 'Push the built image to DockerHub'
required: false
default: false
type: boolean
custom_tag:
description: "Optional extra tag (e.g. 'test-xyz'). Branch name is always tagged."
required: false
type: string

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 "src/sn-auth/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-auth
tags: |
# Clean branch name (e.g., feature-conditional-recaptcha)
type=ref,event=branch
# 'latest' tag only when pushing to main or master (regardless of default branch)
type=raw,value=latest,enable=${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
# 'preview' tag only when pushing to develop
type=raw,value=preview,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
# PR number for pull requests
type=ref,event=pr
# Optional custom tag from manual workflow_dispatch
type=raw,value=${{ inputs.custom_tag }},enable=${{ github.event_name == 'workflow_dispatch' && inputs.custom_tag != '' }}

- name: Login to DockerHub
if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_image))
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: ./src/sn-auth/Dockerfile
push: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_image) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions src/sn-auth/Models/Options/EmailSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public class EmailSettings
public string Password { get; set; } = string.Empty;
public string FromEmail { get; set; } = string.Empty;
public string FromName { get; set; } = string.Empty;
public bool EnableSsl { get; set; } = true;
}
2 changes: 1 addition & 1 deletion src/sn-auth/Services/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void SendEmail(string toEmail, string subject, string emailBody)
using var client = new SmtpClient(_emailSettings.Server, _emailSettings.Port);
if (!string.IsNullOrEmpty(_emailSettings.Username) && !string.IsNullOrEmpty(_emailSettings.Password))
client.Credentials = new NetworkCredential(_emailSettings.Username, _emailSettings.Password);
client.EnableSsl = true;
client.EnableSsl = _emailSettings.EnableSsl;

var mailMessage = new MailMessage
{
Expand Down
3 changes: 2 additions & 1 deletion src/sn-auth/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"Server": "",
"Port": 0,
"FromEmail": "",
"FromName": ""
"FromName": "",
"EnableSsl": true
},
"Registration": {
"IsEnabled": false,
Expand Down
Loading