-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Upload to Azure Blob Storage, Generate SAS Token, and Notify Teams | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
message: | ||
description: 'Message to include in Teams notification' | ||
required: true | ||
default: 'File uploaded to Azure Blob Storage successfully!' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Create a text file | ||
run: echo "Hello, World!" > simplefile.txt | ||
|
||
- name: Log in to Azure | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Upload file to Blob Storage | ||
run: | | ||
az storage blob upload --account-name poweraccelerators --container-name accelerators --name simplefile.txt --file simplefile.txt --auth-mode login | ||
- name: Generate SAS Token | ||
run: | | ||
$expiry = (Get-Date).AddDays(365).ToString("yyyy-MM-ddTHH:mm:ssZ") | ||
$sas = az storage blob generate-sas --account-name poweraccelerators --container-name accelerators --name simplefile.txt --permissions r --expiry $expiry --auth-mode login --output tsv | ||
echo "SAS_URL=https://poweraccelerators.blob.core.windows.net/accelerators/simplefile.txt?$sas" >> $GITHUB_ENV | ||
shell: pwsh | ||
|
||
- name: Post Adaptive Card to Microsoft Teams | ||
run: | | ||
$body = @{ | ||
type = "message" | ||
attachments = @( | ||
@{ | ||
contentType = "application/vnd.microsoft.card.adaptive" | ||
contentUrl = $null | ||
content = @{ | ||
'$schema' = "http://adaptivecards.io/schemas/adaptive-card.json" | ||
type = "AdaptiveCard" | ||
version = "1.2" | ||
body = @( | ||
@{ | ||
type = "TextBlock" | ||
text = "${{ env.SAS_URL }}" | ||
} | ||
) | ||
actions = @( | ||
@{ | ||
type = "Action.OpenUrl" | ||
title = "Download Azure Blob File" | ||
url = "${{ env.SAS_URL }}" | ||
} | ||
) | ||
} | ||
} | ||
) | ||
} | ConvertTo-Json -Depth 10 | ||
curl -H "Content-Type: application/json" -d "$body" ${{ secrets.TEAMS_WEBHOOK_URL }} | ||
shell: pwsh |