Skip to content

Commit

Permalink
feat: added CI/CD azure pipeline for deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel445Ar committed Nov 4, 2023
1 parent 7da7471 commit 01efa35
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
77 changes: 77 additions & 0 deletions .github/workflows/PerustarsDDDAPI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build and deploy .NET Core application to Web App PerustarsDDDAPI with API Management Service PeruStarsDDDAPIManagementService-PeruStarsDDDAPIManagement
on:
push:
branches:
- develop
env:
AZURE_WEBAPP_NAME: PerustarsDDDAPI
AZURE_WEBAPP_PACKAGE_PATH: PERUSTARS/publish
AZURE_APIM_RESOURCE_PATH: /perustarsddd
AZURE_APIM_RESOURCEGROUP: peru-stars
AZURE_APIM_SERVICENAME: PeruStarsDDDAPIManagementService
AZURE_APIM_API_ID: PeruStarsDDDAPIManagement
AZURE_APIM_APPSERVICEURL: https://perustarsdddapi.azurewebsites.net
SWASHBUCLE_ASPNET_CORE_CLI_PACKAGE_VERSION: 5.6.3
SWASHBUCKLE_DOTNET_CORE_VERSION: 3.1.x
API_IMPORT_SPECIFICATION_PATH: PERUSTARS/publish/swagger.json
API_IMPORT_DLL: PERUSTARS/bin/Release/net5.0/PERUSTARS.dll
API_IMPORT_VERSION: v1
CONFIGURATION: Release
DOTNET_CORE_VERSION: 5.0.x
WORKING_DIRECTORY: PERUSTARS
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/[email protected]
with:
include-prerelease: True
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Setup SwashBuckle .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.SWASHBUCKLE_DOTNET_CORE_VERSION }}
- name: Restore
run: dotnet restore ${{ env.WORKING_DIRECTORY }}
- name: Build
run: dotnet build ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test ${{ env.WORKING_DIRECTORY }} --no-build
- name: Publish
run: dotnet publish ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-build --output ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Install Swashbuckle CLI .NET Global Tool
run: dotnet tool install --global Swashbuckle.AspNetCore.Cli --version ${{ env.SWASHBUCLE_ASPNET_CORE_CLI_PACKAGE_VERSION }}
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Generate Open API Specification Document
run: swagger tofile --output "${{ env.API_IMPORT_SPECIFICATION_PATH }}" "${{ env.API_IMPORT_DLL }}" "${{ env.API_IMPORT_VERSION }}"
- name: Publish Artifacts
uses: actions/[email protected]
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.PerustarsDDDAPI_FFFF }}
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.PeruStarsDDDAPIManagementService_SPN }}
- name: Import API into Azure API Management
run: az apim api import --path "${{ env.AZURE_APIM_RESOURCE_PATH }}" --resource-group "${{ env.AZURE_APIM_RESOURCEGROUP }}" --service-name "${{ env.AZURE_APIM_SERVICENAME }}" --api-id "${{ env.AZURE_APIM_API_ID }}" --service-url "${{ env.AZURE_APIM_APPSERVICEURL }}" --specification-path "${{ env.API_IMPORT_SPECIFICATION_PATH }}" --specification-format OpenApi --subscription-required false
- name: logout
run: >
az logout
2 changes: 1 addition & 1 deletion PERUSTARS/PERUSTARS/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ConnectionStrings": {

//"DefaultConnection1": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
"DefaultConnection": "server=localhost;port=3306;database=perustars;uid=root;password=root"
"DefaultConnection": "server=perustars-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Miguel445"
//"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",
//"DefaultConnection": "Server=bufyroukqdunhwcivvpo-mysql.services.clever-cloud.com;Database=bufyroukqdunhwcivvpo;Uid=ubcldvvxbrtlhp2d;Pwd=FltJthiJHLXaKDmKT11O"
//"PostgreSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
Expand Down

0 comments on commit 01efa35

Please sign in to comment.