Skip to content

Initial commit

Initial commit #1

Workflow file for this run

# GitHub Actions Workflow for ShippingApp CI/CD
#
# This workflow automates the build, test, and deployment process for the ShippingApp.
# It is triggered on push and pull request events to ensure code quality and facilitate
# continuous integration and delivery.
#
# Workflow Overview:
# - Triggers: Runs on push to master/main branches and on pull requests
# - Jobs: Build, test, and optionally deploy the application
# - Environment: Configurable for different deployment targets (dev, staging, production)
#
# Prerequisites:
# - Repository secrets should be configured for sensitive data (API keys, credentials)
# - Node.js/Java/Python runtime environment (depending on your app stack)
# - Test frameworks and dependencies properly configured in the project
#
# Customization:
# - Modify trigger branches as needed for your branching strategy
# - Add additional jobs for security scanning, code quality checks, etc.
# - Configure deployment steps based on your infrastructure (AWS, Azure, GCP, etc.)
name: Docker CI/CD Pipeline
on:
push:
branches: [ feature/manuals]
env:
DOCKER_REGISTRY: docker.io
IMAGE_NAME: easternshipping/api
DOTNET_VERSION: '9.0.x'
jobs:
# Stage 1: Build & Test
build-and-test:
name: πŸ—οΈ Build & Test Application
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout code
uses: actions/checkout@v4
- name: πŸ”§ Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: πŸ“¦ Restore dependencies
run: dotnet restore ShippingRules.Api.slnf
- name: πŸ—οΈ Build solution
run: dotnet build ShippingRules.Api.slnf --configuration Release --no-restore
- name: πŸ§ͺ Run tests
run: |
if [ -d "tests" ]; then
dotnet test tests/**/*.csproj --configuration Release --verbosity normal --logger trx
else
echo "No tests found, skipping test step"
fi
- name: πŸ“Š Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: '**/TestResults/**/*.trx'
- name: βœ… Build Summary
run: |
echo "### πŸ—οΈ Build Complete" >> $GITHUB_STEP_SUMMARY
echo "- .NET Version: ${{ env.DOTNET_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Build Status: βœ… Success" >> $GITHUB_STEP_SUMMARY
# Stage 2: Deploy to Production
deploy-production:
name: πŸš€ Deploy to Production
runs-on: ubuntu-latest
needs: build-and-test
if: github.event.inputs.environment == 'production' || startsWith(github.ref, 'refs/tags/v')
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
steps:
- name: πŸ“₯ Checkout code
uses: actions/checkout@v4
- name: πŸ” Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: πŸš€ Deploy to Azure App Service
id: deploy
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
images: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
- name: πŸ₯ Health Check
run: |
sleep 30
curl --fail --retry 5 --retry-delay 10 ${{ steps.deploy.outputs.webapp-url }}/health || exit 1
- name: πŸ“’ Notify Teams
if: always()
uses: jdcargile/[email protected]
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: "Production Deployment ${{ job.status }}"
notification-color: ${{ job.status == 'success' && '28a745' || 'dc3545' }}
- name: βœ… Production Deployment Summary
run: |
echo "### πŸš€ Production Deployment Complete" >> $GITHUB_STEP_SUMMARY
echo "- Environment: Production" >> $GITHUB_STEP_SUMMARY
echo "- URL: ${{ steps.deploy.outputs.webapp-url }}" >> $GITHUB_STEP_SUMMARY
echo "- Status: βœ… Live" >> $GITHUB_STEP_SUMMARY