Merge pull request #26 from eduardo-paes/development #52
Workflow file for this run
This file contains 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: Deploy WebAPI to Azure | |
env: | |
AZURE_WEBAPP_NAME: ${{ secrets.AZURE_WEBAPP_NAME }} | |
AZURE_WEBAPP_PACKAGE_PATH: "." | |
DOTNET_VERSION: "7.0" | |
PROJECT_PATH: "src/Infrastructure/WebAPI/WebAPI.csproj" | |
WEBAPI_PATH: "src/Infrastructure/WebAPI/" | |
ASPNETCORE_ENVIRONMENT: ${{ secrets.ASPNETCORE_ENVIRONMENT }} | |
on: | |
push: | |
branches: ["staging"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: STAGING | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Set up dependency caching for faster builds | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Create env | |
run: | | |
echo "AZURE_BLOB_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_BLOB_STORAGE_CONNECTION_STRING }} | |
AZURE_BLOB_STORAGE_CONTAINER_NAME=${{ secrets.AZURE_BLOB_STORAGE_CONTAINER_NAME }} | |
POSTGRES_CONNECTION_STRING=${{ secrets.POSTGRES_CONNECTION_STRING }} | |
JWT_AUDIENCE=${{ secrets.JWT_AUDIENCE }} | |
JWT_EXPIRE_IN=${{ secrets.JWT_EXPIRE_IN }} | |
JWT_ISSUER=${{ secrets.JWT_ISSUER }} | |
JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} | |
SEQ_API_KEY=${{ secrets.SEQ_API_KEY }} | |
SEQ_URL=${{ secrets.SEQ_URL }} | |
SMTP_EMAIL_PASSWORD=${{ secrets.SMTP_EMAIL_PASSWORD }} | |
SMTP_EMAIL_USERNAME=${{ secrets.SMTP_EMAIL_USERNAME }} | |
EXECUTE_MIGRATION=${{ secrets.EXECUTE_MIGRATION }}" > src/Infrastructure/WebAPI/.env | |
- name: Set environment variable | |
run: echo "ASPNETCORE_ENVIRONMENT=${{ env.ASPNETCORE_ENVIRONMENT }}" >> $GITHUB_ENV | |
- name: Build with dotnet | |
run: dotnet build ${{env.PROJECT_PATH}} --configuration Release -o ${{env.DOTNET_ROOT}}/dist | |
- name: Dotnet publish | |
run: dotnet publish ${{env.PROJECT_PATH}} -c Release -o ${{env.DOTNET_ROOT}}/myapp | |
- name: Copy XML documentation file | |
run: cp ${{env.DOTNET_ROOT}}/dist/*.xml ${{env.DOTNET_ROOT}}/myapp/ | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: .net-app | |
path: ${{env.DOTNET_ROOT}}/myapp | |
deploy: | |
permissions: | |
contents: none | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: STAGING | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: .net-app | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |