From fa0390e96eb34defa126a44ed10d7ef082278cec Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Mon, 23 Jun 2025 20:54:30 +0530 Subject: [PATCH 1/6] add replicator coverage automation --- .github/workflows/docs-replicator-updates.yml | 67 +++++++++++++++++++ src/data/replicator/coverage.json | 18 ----- 2 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/docs-replicator-updates.yml diff --git a/.github/workflows/docs-replicator-updates.yml b/.github/workflows/docs-replicator-updates.yml new file mode 100644 index 00000000..1d918f0b --- /dev/null +++ b/.github/workflows/docs-replicator-updates.yml @@ -0,0 +1,67 @@ +name: Update Replicator Coverage Docs + +on: + schedule: + - cron: 0 5 * * MON + pull_request: + types: [opened, synchronize] + workflow_dispatch: + inputs: + targetBranch: + required: false + type: string + default: 'master' + +jobs: + update-replicator-docs: + name: Update Replicator Coverage Docs + runs-on: ubuntu-latest + steps: + - name: Checkout docs + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: docs + ref: ${{ github.event.inputs.targetBranch || 'main' }} + + - name: Set up system wide dependencies + run: | + sudo apt-get install jq + - name: Start LocalStack + uses: LocalStack/setup-localstack@v0.2.3 + with: + image-tag: 'latest' + use-pro: true + env: + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + + - name: Create Replicator Coverage + working-directory: docs + run: | + localstack auth set-token ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + localstack replicator resources | jq --indent 4 . > src/data/replicator/coverage.json + + - name: Check for changes + id: check-for-changes + working-directory: docs + run: | + # Check if there are changed files and store the result in resources/diff-check.log + # Check against the PR branch if it exists, otherwise against the main + # Store the result in resources/diff-check.log and store the diff count in the GitHub Action output "diff-count" + mkdir -p resources + (git diff --name-only origin/replicator-coverage-updates src/data/replicator/coverage.json 2>/dev/null || git diff --name-only origin/${{ github.event.inputs.targetBranch || 'main' }} src/data/replicator/coverage.json 2>/dev/null) | tee resources/diff-check.log + echo "diff-count=$(cat resources/diff-check.log | wc -l)" >> $GITHUB_OUTPUT + + - name: Create PR + uses: peter-evans/create-pull-request@v7 + if: ${{ success() && steps.check-for-changes.outputs.diff-count != '0' && steps.check-for-changes.outputs.diff-count != '' }} + with: + path: docs + title: "Update Replicator Coverage Docs" + body: "Automatic updates of replicator supported resources" + branch: "replicator-coverage-updates" + author: "LocalStack Bot " + committer: "LocalStack Bot " + commit-message: "update generated replicator coverage file" + token: ${{ secrets.PRO_ACCESS_TOKEN }} + reviewers: cloutierMat,pinzon diff --git a/src/data/replicator/coverage.json b/src/data/replicator/coverage.json index 1e103d21..d478d935 100644 --- a/src/data/replicator/coverage.json +++ b/src/data/replicator/coverage.json @@ -1,13 +1,4 @@ [ - { - "resource_type": "AWS::EC2::SecurityGroup", - "policy_statements": [ - "cloudformation:GetResource", - "ec2:DescribeSecurityGroups" - ], - "service": "ec2", - "identifier": "GroupId" - }, { "resource_type": "AWS::EC2::Subnet", "policy_statements": [ @@ -85,14 +76,5 @@ ], "service": "ssm", "identifier": "Name" - }, - { - "resource_type": "AWS::SecretsManager::Secret", - "policy_statements": [ - "cloudformation:GetResource", - "secretsmanager:DescribeSecret" - ], - "service": "secretsmanager", - "identifier": "Arn" } ] From 437a41e8f1def8f39cd8b56c5f2f2b8499658528 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Mon, 23 Jun 2025 20:56:40 +0530 Subject: [PATCH 2/6] fix --- .github/workflows/docs-replicator-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-replicator-updates.yml b/.github/workflows/docs-replicator-updates.yml index 1d918f0b..7b3eddfa 100644 --- a/.github/workflows/docs-replicator-updates.yml +++ b/.github/workflows/docs-replicator-updates.yml @@ -22,7 +22,7 @@ jobs: with: fetch-depth: 0 path: docs - ref: ${{ github.event.inputs.targetBranch || 'main' }} + ref: ${{ github.event.inputs.targetBranch || 'master' }} - name: Set up system wide dependencies run: | From f260904fa0262ad37b94b2925aac85643ffc9f0f Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Mon, 23 Jun 2025 21:03:15 +0530 Subject: [PATCH 3/6] testing --- .github/workflows/docs-replicator-updates.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs-replicator-updates.yml b/.github/workflows/docs-replicator-updates.yml index 7b3eddfa..57c82031 100644 --- a/.github/workflows/docs-replicator-updates.yml +++ b/.github/workflows/docs-replicator-updates.yml @@ -27,6 +27,7 @@ jobs: - name: Set up system wide dependencies run: | sudo apt-get install jq + - name: Start LocalStack uses: LocalStack/setup-localstack@v0.2.3 with: @@ -51,6 +52,7 @@ jobs: mkdir -p resources (git diff --name-only origin/replicator-coverage-updates src/data/replicator/coverage.json 2>/dev/null || git diff --name-only origin/${{ github.event.inputs.targetBranch || 'main' }} src/data/replicator/coverage.json 2>/dev/null) | tee resources/diff-check.log echo "diff-count=$(cat resources/diff-check.log | wc -l)" >> $GITHUB_OUTPUT + cat resources/diff-check.log - name: Create PR uses: peter-evans/create-pull-request@v7 From e17ab7b97b65b5de8f15648390155910312be5c0 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Mon, 23 Jun 2025 21:07:02 +0530 Subject: [PATCH 4/6] another fix --- .github/workflows/docs-replicator-updates.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-replicator-updates.yml b/.github/workflows/docs-replicator-updates.yml index 57c82031..1cba3224 100644 --- a/.github/workflows/docs-replicator-updates.yml +++ b/.github/workflows/docs-replicator-updates.yml @@ -47,10 +47,10 @@ jobs: working-directory: docs run: | # Check if there are changed files and store the result in resources/diff-check.log - # Check against the PR branch if it exists, otherwise against the main + # Check against the PR branch if it exists, otherwise against the master # Store the result in resources/diff-check.log and store the diff count in the GitHub Action output "diff-count" mkdir -p resources - (git diff --name-only origin/replicator-coverage-updates src/data/replicator/coverage.json 2>/dev/null || git diff --name-only origin/${{ github.event.inputs.targetBranch || 'main' }} src/data/replicator/coverage.json 2>/dev/null) | tee resources/diff-check.log + (git diff --name-only origin/replicator-coverage-updates src/data/replicator/coverage.json 2>/dev/null || git diff --name-only origin/${{ github.event.inputs.targetBranch || 'master' }} src/data/replicator/coverage.json 2>/dev/null) | tee resources/diff-check.log echo "diff-count=$(cat resources/diff-check.log | wc -l)" >> $GITHUB_OUTPUT cat resources/diff-check.log From cc703799a3f1b0145e98ed67df7b584df7a72d5f Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Mon, 23 Jun 2025 21:12:40 +0530 Subject: [PATCH 5/6] last fix --- .github/workflows/docs-replicator-updates.yml | 1 - src/data/replicator/coverage.json | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs-replicator-updates.yml b/.github/workflows/docs-replicator-updates.yml index 1cba3224..d3b99059 100644 --- a/.github/workflows/docs-replicator-updates.yml +++ b/.github/workflows/docs-replicator-updates.yml @@ -52,7 +52,6 @@ jobs: mkdir -p resources (git diff --name-only origin/replicator-coverage-updates src/data/replicator/coverage.json 2>/dev/null || git diff --name-only origin/${{ github.event.inputs.targetBranch || 'master' }} src/data/replicator/coverage.json 2>/dev/null) | tee resources/diff-check.log echo "diff-count=$(cat resources/diff-check.log | wc -l)" >> $GITHUB_OUTPUT - cat resources/diff-check.log - name: Create PR uses: peter-evans/create-pull-request@v7 diff --git a/src/data/replicator/coverage.json b/src/data/replicator/coverage.json index d478d935..1e103d21 100644 --- a/src/data/replicator/coverage.json +++ b/src/data/replicator/coverage.json @@ -1,4 +1,13 @@ [ + { + "resource_type": "AWS::EC2::SecurityGroup", + "policy_statements": [ + "cloudformation:GetResource", + "ec2:DescribeSecurityGroups" + ], + "service": "ec2", + "identifier": "GroupId" + }, { "resource_type": "AWS::EC2::Subnet", "policy_statements": [ @@ -76,5 +85,14 @@ ], "service": "ssm", "identifier": "Name" + }, + { + "resource_type": "AWS::SecretsManager::Secret", + "policy_statements": [ + "cloudformation:GetResource", + "secretsmanager:DescribeSecret" + ], + "service": "secretsmanager", + "identifier": "Arn" } ] From 02f777fde62c81ff6309605e547a32ff80cd9365 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Mon, 23 Jun 2025 21:15:45 +0530 Subject: [PATCH 6/6] last fix --- .github/workflows/docs-replicator-updates.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docs-replicator-updates.yml b/.github/workflows/docs-replicator-updates.yml index d3b99059..4888a8e0 100644 --- a/.github/workflows/docs-replicator-updates.yml +++ b/.github/workflows/docs-replicator-updates.yml @@ -3,8 +3,6 @@ name: Update Replicator Coverage Docs on: schedule: - cron: 0 5 * * MON - pull_request: - types: [opened, synchronize] workflow_dispatch: inputs: targetBranch: