Skip to content

Commit

Permalink
Merge pull request #6 from Altinn/#722-New-action
Browse files Browse the repository at this point in the history
#722: Optimized CI/CD for all envs.
  • Loading branch information
kurt70 authored Nov 7, 2024
2 parents d702c78 + 76462a8 commit b3f12cb
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 94 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/CI-CD-Feedpoller-function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: CI/CD feedpoller-func

on:
push:
branches:
- main

env:
DOTNET_VERSION: '6.0.x' # Global environment variables
TEST_FUNC_NAME: 'oed-test-feedpoller-func'
PROD_FUNC_NAME: 'oed-feedpoller-func'

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: GitHub metadata
run: |
echo "$GITHUB_REPOSITORY on $GITHUB_REF_NAME by $GITHUB_ACTOR"
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet publish -c Release -o ./publish

- name: Run Tests
run: dotnet test --verbosity normal

- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: published-artifacts
path: ./publish/

deploy-to-test:
name: Deploy to Test Environment
needs: build
runs-on: ubuntu-latest
environment:
name: test

steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: published-artifacts
path: ./publish/

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: deploy-to-function
with:
app-name: '${{ env.TEST_FUNC_NAME }}'
slot-name: 'Production'
package: "${{env.GITHUB_WORKSPACE}}/publish/"
publish-profile: ${{ secrets.PUBLISH_PROFILE }}

deploy-to-prod:
name: Deploy to Production Environment
needs: deploy-to-test
runs-on: ubuntu-latest
environment:
name: production

steps:
- name: Await Manual Approval
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo "Waiting for manual approval"
echo "::pause::"
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: published-artifacts
path: ./publish/

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: deploy-to-function
with:
app-name: '${{ env.PROD_FUNC_NAME}}'
slot-name: 'Production'
package: "${{env.GITHUB_WORKSPACE}}/publish/"
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
47 changes: 0 additions & 47 deletions .github/workflows/prod-build_n_deploy-feedpoller-func.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/test-build_n_deploy-feedpoller-func.yml

This file was deleted.

0 comments on commit b3f12cb

Please sign in to comment.