Skip to content

Commit

Permalink
ci: workflows to show the latest modiefied files in S3 package repo
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenruizdegauna committed Dec 24, 2024
1 parent 73fb6b2 commit d25760a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/repository_lastet_added_files.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
name: . 🔍🔍 Show the latest added files into the S3 repository
name: . 🔍🔍 Show N files added before and after datetime into the S3 repository

on:
workflow_dispatch:
inputs:
count:
description: 'Show the latest N packages'
description: 'Amount of files to show'
type: string
default: '500'
required: true
date_time:
description: 'Date and time to show files added before and after (YYYY-MM-DD HH:MM:SS)'
type: string
default: '1000'
required: true

jobs:
scan-deps:
list-files:
name: List latest added packages into the S3 repository
runs-on: ubuntu-20.04
steps:
- name: List latest packages in S3
- name: Validate datetime
run: |
datetime="${{ github.event.inputs.date_time }}"
# Regular expression to match the format YYYY-MM-DD HH:MM:SS
regex="^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$"
if [[ $datetime =~ $regex ]]; then
# Use date command to check if it's a valid date
date -d "$datetime" >/dev/null 2>&1 || exit 1
else
exit 1
fi

- name: List files created before and after datetime in S3
run: |
TZ="UTC" aws s3 ls s3://nr-downloads-main/infrastructure_agent/ --recursive | sort | grep -E "\.(rpm|deb)$" | tail -n ${{ github.event.inputs.count }}
TZ="UTC" aws s3 ls s3://nr-downloads-main/infrastructure_agent/ --recursive | sort | grep --color -m 1 -C {{ github.event.inputs.count }} "^${{ github.event.inputs.date_time }}"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/repository_lastet_added_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: . 🔍🔍 Show the latest added files into the S3 repository

on:
workflow_dispatch:
inputs:
count:
description: 'Show the latest N packages'
type: string
default: '1000'
required: true

jobs:
list-packages:
name: List latest added packages into the S3 repository
runs-on: ubuntu-20.04
steps:
- name: List latest packages in S3
run: |
TZ="UTC" aws s3 ls s3://nr-downloads-main/infrastructure_agent/ --recursive | sort | grep -E "\.(rpm|deb)$" | tail -n ${{ github.event.inputs.count }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
AWS_ROLE_ARN: ${{ secrets.OHAI_AWS_ROLE_ARN_PRODUCTION }}
AWS_ROLE_SESSION_NAME: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_PRODUCTION }}

0 comments on commit d25760a

Please sign in to comment.