forked from erant10/sentinel-content-2
-
Notifications
You must be signed in to change notification settings - Fork 6
80 lines (71 loc) · 3.06 KB
/
sentinel-deploy-3dc42d6f-792f-4388-9a28-73ad513001d5.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Deploy Content to vidhi-CICD [3dc42d6f-792f-4388-9a28-73ad513001d5]
# Note: This workflow will deploy everything in the root directory.
# To deploy content only from a specific path (for example SentinelContent):
# 1. Add the target path to the "paths" property like such
# paths:
# - 'SentinelContent/**'
# - '!.github/workflows/**'
# - '.github/workflows/sentinel-deploy-3dc42d6f-792f-4388-9a28-73ad513001d5.yml'
# 2. Append the path to the directory environment variable below
# directory: '${{ github.workspace }}/SentinelContent'
on:
push:
branches: [ main ]
paths:
- 'Detections/Sample/Test/**'
- '!.github/workflows/**' # this filter prevents other workflow changes from triggering this workflow
- '.github/workflows/sentinel-deploy-3dc42d6f-792f-4388-9a28-73ad513001d5.yml'
jobs:
deploy-content:
runs-on: windows-latest
env:
resourceGroupName: 'cac-test-rg'
workspaceName: 'vidhi-CICD'
workspaceId: '6d46f6c8-a6f2-4306-9117-65b9383b2b4a'
directory: '${{ github.workspace }}/Detections/Sample/Test'
cloudEnv: 'AzureCloud'
creds: ${{ secrets.AZURE_SENTINEL_CREDENTIALS_3dc42d6f792f43889a2873ad513001d5 }}
contentTypes: 'AnalyticsRule'
branch: 'main'
sourceControlId: '3dc42d6f-792f-4388-9a28-73ad513001d5'
githubAuthToken: ${{ secrets.GITHUB_TOKEN }}
smartDeployment: 'true'
steps:
- name: Login to Azure (Attempt 1)
continue-on-error: true
id: login1
uses: azure/login@v1
if: ${{ env.cloudEnv == 'AzureCloud' }}
with:
creds: ${{ secrets.AZURE_SENTINEL_CREDENTIALS_3dc42d6f792f43889a2873ad513001d5 }}
enable-AzPSSession: true
- name: Wait 30 seconds if login attempt 1 failed
if: ${{ env.cloudEnv == 'AzureCloud' && steps.login1.outcome=='failure' }}
run: powershell Start-Sleep -s 30
- name: Login to Azure (Attempt 2)
continue-on-error: true
id: login2
uses: azure/login@v1
if: ${{ env.cloudEnv == 'AzureCloud' && steps.login1.outcome=='failure' }}
with:
creds: ${{ secrets.AZURE_SENTINEL_CREDENTIALS_3dc42d6f792f43889a2873ad513001d5 }}
enable-AzPSSession: true
- name: Wait 30 seconds if login attempt 2 failed
if: ${{ env.cloudEnv == 'AzureCloud' && steps.login2.outcome=='failure' }}
run: powershell Start-Sleep -s 30
- name: Login to Azure (Attempt 3)
continue-on-error: false
id: login3
uses: azure/login@v1
if: ${{ env.cloudEnv == 'AzureCloud' && steps.login2.outcome=='failure' }}
with:
creds: ${{ secrets.AZURE_SENTINEL_CREDENTIALS_3dc42d6f792f43889a2873ad513001d5 }}
enable-AzPSSession: true
- name: Checkout
uses: actions/checkout@v1
- name: Deploy Content to Azure Sentinel
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
inlineScript: |
${{ github.workspace }}//.github/workflows/azure-sentinel-deploy-3dc42d6f-792f-4388-9a28-73ad513001d5.ps1