Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Nov 29, 2021
1 parent 07eee22 commit 12a148a
Show file tree
Hide file tree
Showing 513 changed files with 22,965 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
38 changes: 38 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '15 21 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp', 'javascript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
113 changes: 113 additions & 0 deletions .github/workflows/podcast-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Podcast API CICD

on:
push:
branches: [ main ]
paths:
- 'src/Services/Podcasts/**'
- 'deploy/Services/api.deployment.json'
- '.github/workflows/podcast-api.yml'
pull_request:
branches: [ main ]
paths:
- 'src/Services/Podcasts/**'
- '.github/workflows/podcast-api.yml'

workflow_dispatch:

jobs:

build-pr:
if: ${{ github.event_name == 'pull_request'}}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Build Podcast Updater
run: docker build -f ./src/Services/Podcasts/Podcast.Updater.Worker/Dockerfile -t ${{ secrets.ACR_NAME }}.azurecr.io/podcastupdaterworker:${{ github.sha }} .

- name: Build Podcast API
run: docker build -f ./src/Services/Podcasts/Podcast.API/Dockerfile -t ${{ secrets.ACR_NAME }}.azurecr.io/podcastapi:${{ github.sha }} .

- name: Build Podcast Ingestion
run: docker build -f ./src/Services/Podcasts/Podcast.Ingestion.Worker/Dockerfile -t ${{ secrets.ACR_NAME }}.azurecr.io/podcastingestionworker:${{ github.sha }} .

build-and-push:
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.merged == true) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true

- name: Deploy ACR
uses: azure/powershell@v1
with:
azPSVersion: '3.1.0'
inlineScript: |
az deployment group create -n ghactionbgtasks${{ github.sha }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --template-file deploy/Services/acr.deployment.json --parameters acrName=${{secrets.ACR_NAME}}
- name: Login to ACR
uses: docker/login-action@v1
with:
registry: ${{ secrets.ACR_NAME }}.azurecr.io
username: ${{ fromJson(secrets.AZURE_CREDENTIALS).clientId }}
password: ${{ fromJson(secrets.AZURE_CREDENTIALS).clientSecret }}

- name: Build Podcast Updater
run: |
docker build -f ./src/Services/Podcasts/Podcast.Updater.Worker/Dockerfile -t ${{ secrets.ACR_NAME }}.azurecr.io/podcastupdaterworker:${{ github.sha }} .
docker push ${{ secrets.ACR_NAME }}.azurecr.io/podcastupdaterworker:${{ github.sha }}
- name: Build Podcast API
run: |
docker build -f ./src/Services/Podcasts/Podcast.API/Dockerfile -t ${{ secrets.ACR_NAME }}.azurecr.io/podcastapi:${{ github.sha }} .
docker push ${{ secrets.ACR_NAME }}.azurecr.io/podcastapi:${{ github.sha }}
- name: Build Podcast Ingestion
run: |
docker build -f ./src/Services/Podcasts/Podcast.Ingestion.Worker/Dockerfile -t ${{ secrets.ACR_NAME }}.azurecr.io/podcastingestionworker:${{ github.sha }} .
docker push ${{ secrets.ACR_NAME }}.azurecr.io/podcastingestionworker:${{ github.sha }}
deploy:
needs: build-and-push
environment:
name: prod
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.merged == true) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true

- name: Deploy Container Apps
uses: azure/powershell@v1
with:
azPSVersion: '3.1.0'
failOnStandardError: true
inlineScript: |
$ACR_LOGIN_SERVER="${{secrets.ACR_NAME}}.azurecr.io"
$ACR_PASSWORD=$(az acr credential show -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n ${{secrets.ACR_NAME}} -o tsv --query passwords[0].value)
az deployment group create -n ghaction${{ github.sha }} `
--resource-group ${{secrets.AZURE_RESOURCE_GROUP_NAME}} `
--template-file deploy/Services/api.deployment.json `
--parameters acrPassword=$ACR_PASSWORD acrLogin=${{secrets.ACR_NAME}} acrLoginServer=$ACR_LOGIN_SERVER imageTag=${{ github.sha }} administratorLogin=${{secrets.PODCASTDB_USER_LOGIN}} administratorLoginPassword=${{secrets.PODCASTDB_USER_PASSWORD}} storageAccountName=${{ secrets.STORAGE_NAME }} serverName=${{secrets.PODCASTDB_SERVER_NAME}} kubernetesEnvName=${{secrets.KUBERNETES_ENV_NAME}} workspaceName=${{secrets.WORKSPACE_NAME}}
if( $LASTEXITCODE -ne 0 ) { exit -1 }
- name: Upload Images
uses: azure/powershell@v1
with:
azPSVersion: '3.1.0'
inlineScript: |
cd deploy/Images
./Deploy-Images.ps1 -resourceGroup ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -storageName ${{ secrets.STORAGE_NAME }}
75 changes: 75 additions & 0 deletions .github/workflows/podcast-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Podcast Hub CICD

on:
push:
branches: [ main ]
paths:
- 'src/Services/ListenTogether/**'
- 'deploy/Services/hub.deployment.json'
- '.github/workflows/podcast-hub.yml'
pull_request:
branches: [ main ]
paths:
- 'src/Services/ListenTogether/**'
- '.github/workflows/podcast-hub.yml'

workflow_dispatch:

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Build
run: dotnet build --configuration Release src/Services/ListenTogether/ListenTogether.Hub

- name: Publish
run: dotnet publish --configuration Release src/Services/ListenTogether/ListenTogether.Hub --output hub

- uses: actions/upload-artifact@master
with:
name: drop
path: hub

deploy:
needs: build
environment:
name: prod
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.merged == true) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true

- name: Deploy ARM
uses: azure/powershell@v1
with:
azPSVersion: '3.1.0'
inlineScript: |
az extension add --source https://workerappscliextension.blob.core.windows.net/azure-cli-extension/containerapp-0.2.0-py2.py3-none-any.whl --yes
$PODCAST_API_URL ="https://"+$(az containerapp show -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n podcastapica -o tsv --query configuration.ingress.fqdn)+"/"
az deployment group create -n ghactionlistentogether${{ github.sha }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --template-file deploy/Services/hub.deployment.json --parameters webAppName=${{secrets.HUB_WEBAPP_NAME}} servicePlanName=${{secrets.SERVICE_PLAN_NAME}} podcastApiUrl=$PODCAST_API_URL administratorLogin=${{secrets.PODCASTDB_USER_LOGIN}} administratorLoginPassword=${{secrets.PODCASTDB_USER_PASSWORD}} serverName=${{secrets.PODCASTDB_SERVER_NAME}}
- uses: actions/download-artifact@master
with:
name: drop
path: hub

- name: Azure WebApp
uses: Azure/webapps-deploy@v2
with:
app-name: ${{ secrets.HUB_WEBAPP_NAME }}
package: hub

123 changes: 123 additions & 0 deletions .github/workflows/podcast-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Podcast Web CICD

on:
push:
branches: [main]
paths:
- "src/Web/**"
- ".github/workflows/podcast-web.yml"
- "deploy/Web/web.deployment.json"
pull_request:
branches: [main]
paths:
- "src/Web/**"
- ".github/workflows/podcast-web.yml"
- "deploy/Web/web.deployment.json"
workflow_dispatch:

env:
API_RESOURCE_NAME: podcastapica

jobs:
build:
environment:
name: prod
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"

- name: Install wasm-tools
run: dotnet workload install wasm-tools

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

- name: Set backend env variables
uses: azure/powershell@v1
with:
azPSVersion: "latest"
inlineScript: |
az extension add --source https://workerappscliextension.blob.core.windows.net/azure-cli-extension/containerapp-0.2.0-py2.py3-none-any.whl --yes
az provider register --namespace Microsoft.Web
$apiUrl = "https://$(az containerapp show -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -n ${{ env.API_RESOURCE_NAME }} -o tsv --query configuration.ingress.fqdn)"
$listenTogetherHubUrl = "https://${{ secrets.HUB_WEBAPP_NAME }}.azurewebsites.net/listentogether"
echo "PODCAST_API_URL=$apiUrl" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "LISTEN_TOGETHER_HUB_URL=$listenTogetherHubUrl" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Set Blazor WASM app settings
uses: microsoft/variable-substitution@v1
with:
files: 'src/Web/Client/wwwroot/appsettings.json'
env:
PodcastApi.BaseAddress: ${{ env.PODCAST_API_URL }}
ListenTogetherHub: ${{ env.LISTEN_TOGETHER_HUB_URL }}

- name: Build
run: dotnet build src/Web/Server --configuration Release

- name: Publish
run: dotnet publish --configuration Release src/Web/Server --output web

- uses: actions/upload-artifact@master
with:
name: drop
path: web

outputs:
PodcastApiUrl: ${{ env.PODCAST_API_URL }}
ListenTogetherHubUrl: ${{ env.LISTEN_TOGETHER_HUB_URL }}

deploy:
needs: build
environment:
name: prod
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Deploy ARM
uses: azure/powershell@v1
with:
azPSVersion: "3.1.0"
inlineScript: |
az deployment group create -n ghaction -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --template-file deploy/Web/web.deployment.json --parameters webAppName=${{secrets.WEBAPP_NAME}} servicePlanName=${{secrets.SERVICE_PLAN_NAME}} servicePlanSku=${{secrets.SERVICE_PLAN_SKU}}
- name: Download web artifacts
uses: actions/download-artifact@master
with:
name: drop
path: web

- name: Update App Service app settings variables
uses: Azure/appservice-settings@v1
with:
app-name: ${{ secrets.WEBAPP_NAME }}
app-settings-json: |
[
{
"name": "PodcastApi__BaseAddress",
"value": "${{ needs.build.outputs.PodcastApiUrl }}"
},
{
"name": "ListenTogetherHub",
"value": "${{ needs.build.outputs.ListenTogetherHubUrl }}"
}
]
- name: Azure WebApp
uses: Azure/webapps-deploy@v2
with:
app-name: ${{ secrets.WEBAPP_NAME }}
package: web
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,4 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
*.DS_Store
9 changes: 9 additions & 0 deletions CODE_OF_CONDUCT (2).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
Loading

0 comments on commit 12a148a

Please sign in to comment.