Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move ci/cd pipeline to repo #131

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/core-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: Dan.Core CI/CD
name: Dan.Core CI/CD [Deprecated]
on:
push:
branches: [ master ]
paths-ignore:
- '**/README.md'
- '**/*.yml'
workflow_dispatch:
jobs:
run:
Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/core-cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Dan.Core CI/CD
on:
push:
branches: [ master ]
paths-ignore:
- '**/README.md'
- '**/*.yml'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: 'Dotnet restore, build & test'
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
working-directory: './'
- name: Dotnet build and publish Function App with configuration 'Release'
run: |
dotnet build --configuration 'Release'
dotnet publish -c 'Release' --no-restore -o './published-app'
working-directory: 'Dan.Core'
- name: Upload artifact 'dan-core'
uses: actions/upload-artifact@v3
with:
name: 'dan-core'
path: Dan.Core/published-app

deploy-dev:
runs-on: ubuntu-latest
environment: 'dev'
needs: [build]
steps:
- name: 'Download artifact for dev'
uses: actions/download-artifact@v3
with:
name: 'dan-core'
path: './downloaded-app'
- name: 'Deploy artifact to dev'
uses: azure/functions-action@v1
with:
app-name: ${{secrets.FUNCTIONAPP_NAME}}
package: './downloaded-app'
publish-profile: ${{secrets.AZURE_FUNCTION_PUBLISH_CREDS}}

post-deploy-dev:
uses: data-altinn-no/deploy-actions/.github/workflows/post-deploy-test.yml@main
needs: [deploy-dev]
with:
environment: 'dev'
secrets:
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
kvname: ${{ secrets.KVNAME }}


deploy-staging:
runs-on: ubuntu-latest
environment: 'staging'
needs: [deploy-dev]
steps:
- name: 'Download artifact for staging'
uses: actions/download-artifact@v3
with:
name: 'dan-core'
path: './downloaded-app'
- name: 'Deploy artifact to staging'
uses: azure/functions-action@v1
with:
app-name: ${{secrets.FUNCTIONAPP_NAME}}
package: './downloaded-app'
publish-profile: ${{secrets.AZURE_FUNCTION_PUBLISH_CREDS}}

post-deploy-staging:
uses: data-altinn-no/deploy-actions/.github/workflows/post-deploy-test.yml@main
needs: [deploy-staging]
with:
environment: 'staging'
secrets:
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
kvname: ${{ secrets.KVNAME }}


swap-staging-prod:
runs-on: ubuntu-latest
environment: 'production'
needs: [deploy-staging]
steps:
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Swap staging and production'
run: |
az webapp deployment slot swap -g '${{ secrets.RESOURCE_GROUP_PROD }}' -n '${{ secrets.FUNCTIONAPP_NAME }}' --slot 'staging' --target-slot 'production'
- name: 'Azure logout'
run: |
az logout

redeploy-staging:
runs-on: ubuntu-latest
environment: 'staging'
needs: [swap-staging-prod]
steps:
- name: 'Download artifact for redeploy to staging'
uses: actions/download-artifact@v3
with:
name: 'dan-core'
path: './downloaded-app'
- name: 'Redeploy artifact to staging'
uses: azure/functions-action@v1
with:
app-name: ${{secrets.FUNCTIONAPP_NAME}}
package: './downloaded-app'
publish-profile: ${{secrets.AZURE_FUNCTION_PUBLISH_CREDS}}

Loading