Skip to content

Commit

Permalink
split workflow into jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
artemious7 committed Oct 22, 2024
1 parent fbdc9c1 commit 365b912
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/provision-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
FUNC_PROJECT: TimeTrackerBot/TimeTrackerBot.csproj

jobs:
deploy-infrastructure:
provision-infrastructure:
name: 'Terraform Apply'
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -117,13 +117,10 @@ jobs:
id: terraformOutputsStep
run: |
echo "FUNCTIONS_APP_NAME=$(terraform -chdir=infra output -raw function_app_name)" >> "$GITHUB_OUTPUT"
build-and-deploy:
name: Build and deploy
build:
name: Build
runs-on: ubuntu-latest
needs: deploy-infrastructure
env:
FUNCTIONS_APP_NAME: ${{ needs.deploy-infrastructure.outputs.functionAppName }}

steps:
- uses: actions/checkout@v4
Expand All @@ -141,15 +138,31 @@ jobs:

- name: Publish
run: dotnet publish "${{ env.WORKING_DIRECTORY }}/${{ env.FUNC_PROJECT }}" --configuration ${{ env.CONFIGURATION }} --output "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}"

- name: Install Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

- name: Login to Azure
uses: azure/login@v2
- name: Upload
uses: actions/upload-artifact@v4
with:
name: published
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [provision-infrastructure, build]
env:
FUNCTIONS_APP_NAME: ${{ needs.provision-infrastructure.outputs.functionAppName }}

steps:
- name: Download
uses: actions/download-artifact@v4
with:
name: published
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}

- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }}

- name: Deploy to Azure Function App
uses: Azure/functions-action@v1
Expand Down

0 comments on commit 365b912

Please sign in to comment.