Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leandromsft committed Aug 19, 2022
0 parents commit 8ef4c88
Show file tree
Hide file tree
Showing 120 changed files with 42,814 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [[email protected]](mailto:[email protected]) with questions or concerns
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
IF SUFFICIENT INFORMATION IS NOT PROVIDED VIA THE FOLLOWING TEMPLATE THE ISSUE MIGHT BE CLOSED WITHOUT FURTHER CONSIDERATION OR INVESTIGATION
-->
> Please provide us with the following information:
> ---------------------------------------------------------------
### This issue is for a: (mark with an `x`)
```
- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
```

### Minimal steps to reproduce
>
### Any log messages given by the failure
>
### Expected/desired behavior
>
### OS and Version?
> Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
### Versions
>
### Mention any other details that might be useful

> ---------------------------------------------------------------
> Thanks! We'll be in touch soon.
45 changes: 45 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Purpose
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
* ...

## Does this introduce a breaking change?
<!-- Mark one with an "x". -->
```
[ ] Yes
[ ] No
```

## Pull Request Type
What kind of change does this Pull Request introduce?

<!-- Please check the one that applies to this PR using "x". -->
```
[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:
```

## How to Test
* Get the code

```
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
```

* Test the code
<!-- Add steps to run the tests suite and/or manually test -->
```
```

## What to Check
Verify that the following are valid
* ...

## Other Information
<!-- Add any other helpful information that may be needed here. -->
43 changes: 43 additions & 0 deletions .github/workflows/aspnetcore-bicep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: aspnetcore.bicep

on: workflow_dispatch

#on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]

env:
AZ_RG_NAME: 'rg-dotnet-containerapp'
AZ_ACR_NAME: 'acrdotnetcontainerapp'
AZ_AKS_NAME: 'aksdotnetcontainerapp'
AZ_SQLSERVER_NAME: 'sqldotnetcontainerapp'

jobs:
build:

runs-on: ubuntu-latest

steps:

# Checkout code
- uses: actions/checkout@v2

# Log into Azure
- name: Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Deploy Bicep file
- name: Deploy Template
uses: Azure/[email protected]
with:
scope: resourcegroup
resourceGroupName: ${{ env.AZ_RG_NAME }}
template: src/aspnetcoreiac/main.bicep
deploymentMode: Incremental
deploymentName: 'gh-actions'
parameters: acrName=${{ env.AZ_ACR_NAME }} clusterName=${{ env.AZ_AKS_NAME }} sqlserverName=${{ env.AZ_SQLSERVER_NAME }}
failOnStdErr: false
32 changes: 32 additions & 0 deletions .github/workflows/aspnetcore-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: aspnetcore.CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CONFIGURATION: Release

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Restore
run: dotnet restore src/aspnetcore.sln

- name: Build
run: dotnet build src/aspnetcore.sln --configuration ${{ env.CONFIGURATION }} --no-restore

- name: Test
run: dotnet test src/aspnetcorewebapi.test/aspnetcorewebapi.test.csproj --configuration ${{ env.CONFIGURATION }} --no-build --verbosity normal --logger trx --results-directory TestResults
151 changes: 151 additions & 0 deletions .github/workflows/aspnetcore-k8s.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: aspnetcore.k8s

on: workflow_dispatch

#on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]

env:
AZ_RG_NAME: 'rg-dotnet-containerapp'
AZ_ACR_NAME: 'acrdotnetcontainerapp'
AZ_AKS_NAME: 'aksdotnetcontainerapp'
AZ_SQLSERVER_NAME: 'sqldotnetcontainerapp'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Change Version variable
uses: microsoft/variable-substitution@v1
with:
files: 'src/aspnetcorewebapp/appsettings.json'
env:
Version: ${{ GITHUB.RUN_NUMBER }}

- name: Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Set the value in bash
id: setup-variables
run: |
url_acr=$(az acr show -n ${{ env.AZ_ACR_NAME }} --query loginServer --output tsv)
login_acr=$(az acr credential show -n ${{ env.AZ_ACR_NAME }} --query username --output tsv)
password_acr=$(az acr credential show -n ${{ env.AZ_ACR_NAME }} --query passwords[0].value --output tsv)
echo "::add-mask::$url_acr"
echo "::add-mask::$login_acr"
echo "::add-mask::$password_acr"
echo "ACR_URL=$url_acr" >> $GITHUB_ENV
echo "ACR_LOGIN=$login_acr" >> $GITHUB_ENV
echo "ACR_PASSWORD=$password_acr" >> $GITHUB_ENV
- name: Docker Login
uses: docker/[email protected]
with:
registry: ${{ env.ACR_URL }}
username: ${{ env.ACR_LOGIN }}
password: ${{ env.ACR_PASSWORD }}

- name: Build and push aspnetcorewebapi image
uses: docker/[email protected]
with:
context: src/aspnetcorewebapi
file: src/aspnetcorewebapi/Dockerfile
tags: |
${{ env.ACR_URL }}/aspnetcorewebapi:${{ GITHUB.RUN_NUMBER }}
${{ env.ACR_URL }}/aspnetcorewebapi:latest
push: true

- name: Build and push aspnetcorewebapp image
uses: docker/[email protected]
with:
context: src/aspnetcorewebapp
file: src/aspnetcorewebapp/Dockerfile
tags: |
${{ env.ACR_URL }}/aspnetcorewebapp:${{ GITHUB.RUN_NUMBER }}
${{ env.ACR_URL }}/aspnetcorewebapp:latest
push: true

- name: Replace variables
run: |
echo Build Number = ${{ GITHUB.RUN_NUMBER }}
urlApp=${{ env.ACR_URL }}/aspnetcorewebapp:${{ GITHUB.RUN_NUMBER }}
urlApi=${{ env.ACR_URL }}/aspnetcorewebapi:${{ GITHUB.RUN_NUMBER }}
sed -i "s|_ImageUrlApp_|$urlApp|g" src/kubernetes-containerapp.yaml
sed -i "s|_ImageUrlApi_|$urlApi|g" src/kubernetes-containerapp.yaml
sed -i "s|_ConnString_|${{ secrets.SQL_CONNECTION }}|g" src/kubernetes-containerapp.yaml
- name: Upload Kubernetes files
uses: actions/[email protected]
with:
name: k8s
path: src/kubernetes-containerapp.yaml

release:
needs: build
runs-on: ubuntu-latest
environment: DEV
steps:
- name: Download k8s artifact
uses: actions/[email protected]
with:
name: k8s
path: my-app-artifact

- name: Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Set the value in bash
id: setup-variables
run: |
url_acr=$(az acr show -n ${{ env.AZ_ACR_NAME }} --query loginServer --output tsv)
login_acr=$(az acr credential show -n ${{ env.AZ_ACR_NAME }} --query username --output tsv)
password_acr=$(az acr credential show -n ${{ env.AZ_ACR_NAME }} --query passwords[0].value --output tsv)
echo "::add-mask::$url_acr"
echo "::add-mask::$login_acr"
echo "::add-mask::$password_acr"
echo "ACR_URL=$url_acr" >> $GITHUB_ENV
echo "ACR_LOGIN=$login_acr" >> $GITHUB_ENV
echo "ACR_PASSWORD=$password_acr" >> $GITHUB_ENV
# Set the target Azure Kubernetes Service (AKS) cluster.
- name: Deploy set context
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: ${{ env.AZ_AKS_NAME }}
resource-group: ${{ env.AZ_RG_NAME }}

# Create image pull secret for ACR
- name: Create k8s secret
uses: azure/k8s-create-secret@v1
with:
container-registry-url: ${{ env.ACR_URL }}
container-registry-username: ${{ env.ACR_LOGIN }}
container-registry-password: ${{ env.ACR_PASSWORD }}
secret-name: mysecret
namespace: default
arguments: --force true

# Deploy app to AKS
- name: Deploy to k8s
uses: azure/k8s-deploy@v1
with:
manifests: my-app-artifact/kubernetes-containerapp.yaml
imagepullsecrets: mysecret
namespace: default
Loading

0 comments on commit 8ef4c88

Please sign in to comment.