Skip to content

Add actions for build/deploy/promote and PR previews, remove k8s infr… #1

Add actions for build/deploy/promote and PR previews, remove k8s infr…

Add actions for build/deploy/promote and PR previews, remove k8s infr… #1

name: Build and stage
env:
AZURE_WEBAPP_PACKAGE_PATH: '.'
DOTNET_VERSION: '8.0'
SLOT_NAME: staging
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
name: Build and publish app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up dependency caching for faster builds
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build with dotnet
run: dotnet build src/Client --configuration Release
- name: dotnet publish
run: dotnet publish src/Client -c Release -o ${{ env.DOTNET_ROOT }}/mainsite
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: Steeltoe-MainSite
path: ${{ env.DOTNET_ROOT }}/mainsite
deploy-to-staging:
name: Deploy to staging environment
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@v4
with:
name: Steeltoe-MainSite
- name: Log into Azure CLI with service principal
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
slot-name: ${{ env.SLOT_NAME }}