From 2674e0ea34301406698148c96a5c253f5b9d0a5a Mon Sep 17 00:00:00 2001 From: Ruben Ruiz de Gauna Date: Wed, 8 Jan 2025 14:41:59 +0100 Subject: [PATCH] ci: flow to list files/pkgs in staging bucket --- .../repository_lastet_added_packages.yml | 24 ---------- ....yml => repository_latest_added_files.yml} | 21 ++++++++- .../repository_latest_added_packages.yml | 44 +++++++++++++++++++ 3 files changed, 64 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/repository_lastet_added_packages.yml rename .github/workflows/{repository_lastet_added_files.yml => repository_latest_added_files.yml} (60%) create mode 100644 .github/workflows/repository_latest_added_packages.yml diff --git a/.github/workflows/repository_lastet_added_packages.yml b/.github/workflows/repository_lastet_added_packages.yml deleted file mode 100644 index 424bc5c1e..000000000 --- a/.github/workflows/repository_lastet_added_packages.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: . 🔍🔍 Show the latest added packages 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 }} diff --git a/.github/workflows/repository_lastet_added_files.yml b/.github/workflows/repository_latest_added_files.yml similarity index 60% rename from .github/workflows/repository_lastet_added_files.yml rename to .github/workflows/repository_latest_added_files.yml index 7b73b1260..51d2114c1 100644 --- a/.github/workflows/repository_lastet_added_files.yml +++ b/.github/workflows/repository_latest_added_files.yml @@ -12,6 +12,14 @@ on: description: 'UTC Date and time to show files added before and after (YYYY-MM-DD HH:MM:SS)' type: string required: true + environment: + type: choice + required: true + description: 'Environment to run the action' + options: + - staging + - production + default: 'staging' jobs: list-files: @@ -31,7 +39,8 @@ jobs: exit 1 fi - - name: List files created before and after datetime in S3 + - name: List files created before and after datetime in Production S3 + if: ${{ github.event.inputs.environment == 'production' }} run: | 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: @@ -39,3 +48,13 @@ jobs: 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 }} + + - name: List files created before and after datetime in Staging S3 + if: ${{ github.event.inputs.environment == 'staging' }} + run: | + TZ="UTC" aws s3 ls s3://nr-downloads-ohai-staging/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_STAGING }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_STAGING }} + AWS_ROLE_ARN: ${{ secrets.OHAI_AWS_ROLE_ARN_STAGING }} + AWS_ROLE_SESSION_NAME: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_STAGING }} diff --git a/.github/workflows/repository_latest_added_packages.yml b/.github/workflows/repository_latest_added_packages.yml new file mode 100644 index 000000000..ebbd1c1a8 --- /dev/null +++ b/.github/workflows/repository_latest_added_packages.yml @@ -0,0 +1,44 @@ +name: . 🔍🔍 Show the latest added packages into the S3 repository + +on: + workflow_dispatch: + inputs: + count: + description: 'Show the latest N packages' + type: string + default: '1000' + required: true + environment: + type: choice + required: true + description: 'Environment to run the action' + options: + - staging + - production + default: 'staging' + + +jobs: + list-packages: + name: List latest added packages into the S3 repository + runs-on: ubuntu-20.04 + steps: + - name: List latest packages in Production S3 + if: ${{ github.event.inputs.environment == 'production' }} + 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 }} + + - name: List latest packages in Staging S3 + if: ${{ github.event.inputs.environment == 'staging' }} + run: | + TZ="UTC" aws s3 ls s3://nr-downloads-ohai-staging/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_STAGING }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_STAGING }} + AWS_ROLE_ARN: ${{ secrets.OHAI_AWS_ROLE_ARN_STAGING }} + AWS_ROLE_SESSION_NAME: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_STAGING }}