Skip to content

Check code freshness #2

Check code freshness

Check code freshness #2

name: Check code freshness
on:
workflow_dispatch:
schedule:
- cron: "0 5 * * 1"
jobs:
check:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::561178107736:role/DevOps-GitHubOidcFederatedRole
role-session-name: GitHubActions-CheckCodeFreshness
- name: Check parameter ages
run: |
threshold=$(date --date="90 days ago" +%FT%H:%M:%SZ)
aws_command="aws ssm describe-parameters --profile prx-legacy --parameter-filters Key=Name,Option=Contains,Values=pkg"
unset NEXT_TOKEN
function process_parameter {
echo $1 | jq '.Name'
}
function parse_output() {
if [ ! -z "$cli_output" ]; then
echo $cli_output | jq -c --arg d "$threshold" '.Parameters[] | select( .Name | contains("/prx/prod/Spire/")) | select(.LastModifiedDate < $d)' | while read param; do
process_parameter $param
done
NEXT_TOKEN=$(echo $cli_output | jq -r ".NextToken")
fi
}
# The command is run and output parsed in the below statements.
cli_output=$($aws_command)
parse_output