Skip to content

Deno

Deno #3

Workflow file for this run

# 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