Skip to content

Commit d25760a

Browse files
ci: workflows to show the latest modiefied files in S3 package repo
1 parent 73fb6b2 commit d25760a

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

.github/workflows/repository_lastet_added_files.yml

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
1-
name: . 🔍🔍 Show the latest added files into the S3 repository
1+
name: . 🔍🔍 Show N files added before and after datetime into the S3 repository
22

33
on:
44
workflow_dispatch:
55
inputs:
66
count:
7-
description: 'Show the latest N packages'
7+
description: 'Amount of files to show'
8+
type: string
9+
default: '500'
10+
required: true
11+
date_time:
12+
description: 'Date and time to show files added before and after (YYYY-MM-DD HH:MM:SS)'
813
type: string
9-
default: '1000'
1014
required: true
1115

1216
jobs:
13-
scan-deps:
17+
list-files:
1418
name: List latest added packages into the S3 repository
1519
runs-on: ubuntu-20.04
1620
steps:
17-
- name: List latest packages in S3
21+
- name: Validate datetime
22+
run: |
23+
datetime="${{ github.event.inputs.date_time }}"
24+
# Regular expression to match the format YYYY-MM-DD HH:MM:SS
25+
regex="^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$"
26+
27+
if [[ $datetime =~ $regex ]]; then
28+
# Use date command to check if it's a valid date
29+
date -d "$datetime" >/dev/null 2>&1 || exit 1
30+
else
31+
exit 1
32+
fi
33+
34+
- name: List files created before and after datetime in S3
1835
run: |
19-
TZ="UTC" aws s3 ls s3://nr-downloads-main/infrastructure_agent/ --recursive | sort | grep -E "\.(rpm|deb)$" | tail -n ${{ github.event.inputs.count }}
36+
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 }}"
2037
env:
2138
AWS_ACCESS_KEY_ID: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }}
2239
AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: . 🔍🔍 Show the latest added files into the S3 repository
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
count:
7+
description: 'Show the latest N packages'
8+
type: string
9+
default: '1000'
10+
required: true
11+
12+
jobs:
13+
list-packages:
14+
name: List latest added packages into the S3 repository
15+
runs-on: ubuntu-20.04
16+
steps:
17+
- name: List latest packages in S3
18+
run: |
19+
TZ="UTC" aws s3 ls s3://nr-downloads-main/infrastructure_agent/ --recursive | sort | grep -E "\.(rpm|deb)$" | tail -n ${{ github.event.inputs.count }}
20+
env:
21+
AWS_ACCESS_KEY_ID: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }}
22+
AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
23+
AWS_ROLE_ARN: ${{ secrets.OHAI_AWS_ROLE_ARN_PRODUCTION }}
24+
AWS_ROLE_SESSION_NAME: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_PRODUCTION }}

0 commit comments

Comments
 (0)