Skip to content

token

token #568

# This is a basic workflow to help you get started with Actions
name: Azure CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_VERSION: '6.0.x'
API_SOLUTION_PATH: src/SwiftTestingFrameworkAPI/SwiftTestingFrameworkAPI.sln
FUNCTION_SOLUTION_PATH: src/Function/Function.sln
# Controls when the workflow will run
on:
# Triggers the workflow on push to "main" branch
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
get-locations:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: Read Locations
id: get-matrix
run: |
content=`cat $GITHUB_WORKSPACE/location_matrix.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/}"
content="${content//$'\r'/'%0D'}"
echo "matrix=$content" >> $GITHUB_OUTPUT
create-resources:
if: "!contains(github.event.commits[0].message, '[skip]')"
needs: get-locations
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-locations.outputs.matrix) }}
steps:
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID}}
tenant-id: ${{ secrets.AZURE_TENANT_ID}}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
- name: Checkout
uses: actions/checkout@v3
- name: Azure CLI script file
uses: azure/CLI@v1
with:
azcliversion: 2.30.0
inlineScript: |
chmod +x $GITHUB_WORKSPACE/deploy.sh
$GITHUB_WORKSPACE/deploy.sh stf-${{ matrix.location }} ${{ matrix.location }} templates/stf-prod.json
build-api-app:
needs: get-locations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Build api with dotnet
run: dotnet build ${{ env.API_SOLUTION_PATH }} --configuration Release
- name: dotnet publish api
run: dotnet publish ${{ env.API_SOLUTION_PATH }} -c Release -o ${{env.DOTNET_ROOT}}/api
- name: Upload api artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: api-app
path: ${{env.DOTNET_ROOT}}/api
retention-days: 1
build-function-app:
needs: get-locations
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Setup NuGet
uses: NuGet/[email protected]
- name: Restore Packages
run: nuget restore ${{ env.FUNCTION_SOLUTION_PATH }}
- name: Build Solution
run: |
msbuild.exe ${{ env.FUNCTION_SOLUTION_PATH }} /p:platform="Any CPU" /p:configuration="Release"
- name: Upload function app artifact
uses: actions/upload-artifact@v3
with:
name: function-app
path: "src/Function/bin/Release/net48/"
retention-days: 1
deploy:
needs: [build-api-app, build-function-app, create-resources, get-locations]
runs-on: ubuntu-latest
if: ${{ !failure() && !cancelled()}}
continue-on-error: true
strategy:
matrix: ${{ fromJson(needs.get-locations.outputs.matrix) }}
steps:
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID}}
tenant-id: ${{ secrets.AZURE_TENANT_ID}}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
- name: Checkout
uses: actions/checkout@v1
- name: Download api artifact from build job
uses: actions/download-artifact@v3
with:
name: api-app
path: api-app
- name: Download function app artifact from build job
uses: actions/download-artifact@v3
with:
name: function-app
path: function-app
- name: Deploy to Azure Windows Web App
id: deploy-to-windows-webapp
uses: azure/webapps-deploy@v3
with:
app-name: stf-${{ matrix.location }}-winapp
package: api-app
- name: Deploy to Azure Linux Web App
id: deploy-to-linux-webapp
uses: azure/webapps-deploy@v3
with:
app-name: stf-${{ matrix.location }}-linuxapp
package: api-app
- name: Deploy to Azure Functions App
id: deploy-to-functionapp
uses: Azure/functions-action@v1
with:
app-name: stf-${{ matrix.location }}-functionapp
package: function-app