-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (65 loc) · 2.84 KB
/
deno.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
81
82
83
84
85
86
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will install Deno then run `deno lint` and `deno test`.
# For more information see: https://github.com/denoland/setup-deno
name: Deno
on:
workflow_dispatch:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4
- name: Check Storage Account Keys Age and Rotate if necessary
id: rotate_keys
run: |
# Set variables
resource_group="YourResourceGroupName"
storage_account="YourStorageAccountName"
key_age_limit=300 # in days
# Function to check and rotate a key if necessary
check_and_rotate_key() {
key_index=$1
key_name=$2
# Get the key creation date
key_creation_date=$(az storage account keys list --resource-group $resource_group --account-name $storage_account --query "[$key_index].creationTime" --output tsv)
# Convert creation date to a Unix timestamp
key_creation_timestamp=$(date -d $key_creation_date +%s)
# Get the current date as a Unix timestamp
current_date=$(date +%s)
# Calculate the difference in days
age_in_days=$(( (current_date - key_creation_timestamp) / 86400 ))
# Check if the key is older than the defined limit
if [ $age_in_days -ge $key_age_limit ]; then
echo "$key_name is $age_in_days days old, triggering rotation."
# Trigger key rotation
az storage account keys renew --resource-group $resource_group --account-name $storage_account --key $key_name
echo "$key_name rotated successfully."
# Set output variable to indicate key rotation
echo "::set-output name=KeyRotated::true"
else
echo "$key_name is $age_in_days days old, no action required."
echo "::set-output name=KeyRotated::false"
fi
}
# Check and rotate the primary key if necessary
check_and_rotate_key 0 "primary"
# Check and rotate the secondary key if necessary
check_and_rotate_key 1 "secondary"
# Exit if no keys were rotated
if [ "$key_rotated" = false ]; then
echo "No keys were rotated. Exiting workflow."
exit 0
fi
# Uncomment this step to verify the use of 'deno fmt' on each commit.
# - name: Verify formatting
# run: deno fmt --check
- name: Run linter
run: deno lint
- name: Run tests
run: deno test -A