Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo committed Jan 3, 2021
2 parents 9390b69 + 614bde6 commit 60b4457
Show file tree
Hide file tree
Showing 65 changed files with 5,562 additions and 3 deletions.
429 changes: 429 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

253 changes: 253 additions & 0 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
name: Build, Test & Deploy

on:
push:
branches:
- dev

env:
FUNCTIONAPP_PATH: 'src/YouTubeWebSubSubscriptionHandler.FunctionApp'

jobs:
arm_template_build_test_deploy_dev:
name: 'DEV: ARM Templates Build, Test & Deploy'

runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Login to Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_DEV }}

- name: Run Bicep build
uses: aliencube/[email protected]
with:
files: '**/*.bicep'

- name: Run ARM TTK
uses: aliencube/[email protected]
id: armtest
with:
path: ./resources

- name: Show ARM TTK test result
shell: bash
continue-on-error: true
run: |
echo 'Results: ${{ toJSON(fromJSON(steps.armtest.outputs.results)) }}'
- name: Deploy ARM templates
id: arm
uses: Azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.SUBSCRIPTION_ID_DEV }}
resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }}
deploymentName: 'ytwebsub'
template: 'resources/azuredeploy.json'
parameters: name=${{ secrets.RESOURCE_NAME }} env=${{ secrets.RESOURCE_ENVIRONMENT_DEV }} locationCode=${{ secrets.RESOURCE_LOCATION_CODE }} functionAppEnvironment=${{ secrets.RESOURCE_FUNCTIONAPP_ENVIRONMENT_DEV }} youtubeApiKey=${{ secrets.YOUTUBE_API_KEY_DEV }} youtubeFetchParts=${{ secrets.YOUTUBE_API_FETCH_PARTS }}

- name: Set EventGrid name
shell: bash
run: |
echo ${{ steps.arm.outputs.eventgridName }} > eventgrid_name_dev.txt
- name: Upload EventGrid name
uses: actions/upload-artifact@v2
with:
name: eventgrid_name_dev
path: eventgrid_name_dev.txt

functionapp_build_test_deploy_dev:
name: 'DEV: FunctionApp Build, Test & Deploy'
needs:
- arm_template_build_test_deploy_dev

runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Login to Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_DEV }}

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

- name: Restore NuGet packages
shell: bash
run: |
dotnet restore .
- name: Build solution
shell: bash
run: |
dotnet build . -c Release
- name: Test solution
shell: bash
run: |
dotnet test . -c Release
- name: Create FunctionApp artifact
shell: bash
run: |
dotnet publish ${{ env.FUNCTIONAPP_PATH }} -c Release -o published
- name: Get FunctionApp publish profile
id: publishprofile
uses: aliencube/publish-profile-actions@v1
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS_DEV }}
with:
resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }}
appName: ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }}

- name: Deploy FunctionApp
uses: Azure/functions-action@v1
with:
app-name: ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }}
package: published
publish-profile: ${{ steps.publishprofile.outputs.profile }}

- name: Reset FunctionApp publish profile
uses: aliencube/publish-profile-actions@v1
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS_DEV }}
with:
resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }}
appName: ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }}
reset: true

- name: Update FunctionApp settings
uses: azure/CLI@v1
with:
inlineScript: |
settings=$(az functionapp config appsettings set \
-g ${{ secrets.RESOURCE_GROUP_NAME_DEV }} \
-n ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }} \
--settings WebSub__CallbackKey=$(az functionapp function keys list \
-g ${{ secrets.RESOURCE_GROUP_NAME_DEV }} \
-n ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }} \
--function-name ${{ secrets.RESOURCE_FUNCTION_NAME_CALLBACK }} \
--query "default" \
-o tsv))
logicapp_build_deploy_dev:
name: 'DEV: LogicApp Build & Deploy'
needs:
- functionapp_build_test_deploy_dev

runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Login to Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_DEV }}

- name: Run Bicep build
uses: aliencube/[email protected]
with:
files: '**/*.bicep'

- name: Deploy LogicApp for scheduled subscription to WebSub
id: websub
uses: Azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.SUBSCRIPTION_ID_DEV }}
resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }}
deploymentName: 'ytwebsub'
template: 'resources/logappdeploy.subscription.json'
parameters: name=${{ secrets.RESOURCE_NAME }} env=${{ secrets.RESOURCE_ENVIRONMENT_DEV }} locationCode=${{ secrets.RESOURCE_LOCATION_CODE }} logicAppSubscriptionTopicUri=${{ secrets.YOUTUBE_TOPIC_URL_DEV }}

- name: Deploy LogicApp as EventGrid subscription handler for Twitter
id: twitter
uses: Azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.SUBSCRIPTION_ID_DEV }}
resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }}
deploymentName: 'ytwebsub'
template: 'resources/logappdeploy.eventgridhandler-twitter.json'
parameters: name=${{ secrets.RESOURCE_NAME }} env=${{ secrets.RESOURCE_ENVIRONMENT_DEV }} locationCode=${{ secrets.RESOURCE_LOCATION_CODE }} youTubeAcceptedTitleSegment=${{ secrets.YOUTUBE_ACCEPTED_TITLE_SEGMENT }} youTubeAcceptedEventType=${{ secrets.ACCEPTED_EVENT_TYPE_YOUTUBE }} twitterProfileId=${{ secrets.TWITTER_PROFILE_ID }}

- name: Deploy LogicApp as EventGrid subscription handler for ReTweet
id: retweeter
uses: Azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.SUBSCRIPTION_ID_DEV }}
resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }}
deploymentName: 'ytwebsub'
template: 'resources/logappdeploy.eventgridhandler-retweeter.json'
parameters: name=${{ secrets.RESOURCE_NAME }} env=${{ secrets.RESOURCE_ENVIRONMENT_DEV }} locationCode=${{ secrets.RESOURCE_LOCATION_CODE }} twitterEventType=${{ secrets.ACCEPTED_EVENT_TYPE_TWITTER }} twitterProfileId=${{ secrets.TWITTER_PROFILE_ID }} retweeterProfileId=${{ secrets.RETWEETER_PROFILE_ID }}

- name: Download EventGrid name
uses: actions/download-artifact@v2
with:
name: eventgrid_name_dev

- name: Get EventGrid name
id: eventgrid
shell: bash
run: |
name=$(cat eventgrid_name_dev.txt)
echo "::set-output name=name::$name"
- name: Provision EventGrid subscription for Twitter
uses: azure/CLI@v1
with:
inlineScript: |
az extension add -n eventgrid
az extension add -n logic
sub=$(az eventgrid event-subscription create \
-n ${{ steps.eventgrid.outputs.name }}-sub-twitter-${{ secrets.TWITTER_PROFILE_ID }} \
--source-resource-id $(az eventgrid topic show \
-g ${{ secrets.RESOURCE_GROUP_NAME_DEV }} \
-n ${{ steps.eventgrid.outputs.name }}-topic \
--query "id" -o tsv) \
--event-delivery-schema cloudeventschemav1_0 \
--endpoint-type webhook \
--endpoint $(az rest \
-m POST \
-u "https://management.azure.com$(az logic workflow show \
-g ${{ secrets.RESOURCE_GROUP_NAME_DEV }} \
-n ${{ steps.twitter.outputs.logicAppName }} \
--query "id" -o tsv)/triggers/manual/listCallbackUrl?api-version=2016-06-01" \
--query "value" -o tsv) \
--advanced-filter type StringBeginsWith ${{ secrets.ACCEPTED_EVENT_TYPE_YOUTUBE }} \
--advanced-filter type StringEndsWith ${{ secrets.ACCEPTED_EVENT_TYPE_YOUTUBE }})
- name: Provision EventGrid subscription for ReTweet
uses: azure/CLI@v1
with:
inlineScript: |
az extension add -n eventgrid
az extension add -n logic
sub=$(az eventgrid event-subscription create \
-n ${{ steps.eventgrid.outputs.name }}-sub-retweeter-${{ secrets.RETWEETER_PROFILE_ID}} \
--source-resource-id $(az eventgrid topic show \
-g ${{ secrets.RESOURCE_GROUP_NAME_DEV }} \
-n ${{ steps.eventgrid.outputs.name }}-topic \
--query "id" -o tsv) \
--event-delivery-schema cloudeventschemav1_0 \
--endpoint-type webhook \
--endpoint $(az rest \
-m POST \
-u "https://management.azure.com$(az logic workflow show \
-g ${{ secrets.RESOURCE_GROUP_NAME_DEV }} \
-n ${{ steps.retweeter.outputs.logicAppName }} \
--query "id" -o tsv)/triggers/manual/listCallbackUrl?api-version=2016-06-01" \
--query "value" -o tsv) \
--advanced-filter type StringBeginsWith ${{ secrets.ACCEPTED_EVENT_TYPE_TWITTER }} \
--advanced-filter type StringEndsWith ${{ secrets.ACCEPTED_EVENT_TYPE_TWITTER }})
Loading

0 comments on commit 60b4457

Please sign in to comment.