From b48b79bea6081c3aeb8da56af3240d0be3f34312 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Date: Thu, 12 Dec 2024 16:30:27 +0100 Subject: [PATCH] DAT-19181 GitHub Actions Error: uploading S3 Object to Bucket (#285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ (send-docs-redirects-to-staging.yml): add a check for website_redirect format to ensure all values start with a forward slash for consistency and correctness in redirect paths * 📝 (variables.tf): add a comment to indicate the need for a list of redirects from team members to clarify requirements * 📝 (send-docs-redirects-to-staging.yml): improve validation for website_redirect format to ensure it starts with '/' or 'http' 💡 (variables.tf): remove unnecessary trailing whitespace for cleaner code * 📝 (variables.tf): add a comment placeholder for obtaining redirect list from team members * ♻️ (variables.tf): update redirect path to remove leading slash for consistency in URL formatting * ♻️ (variables.tf): update redirect path to include leading slash for consistency and correctness in URL structure * ✨ (send-enterprise-redirects-to-staging.yml): add a step to check the format of website_redirect entries to ensure valid URLs 💡 (send-enterprise-redirects-to-staging.yml): provide error messages and examples for invalid website_redirect formats to guide users --- .../send-docs-redirects-to-staging.yml | 17 +++++++++++++++++ .../send-enterprise-redirects-to-staging.yml | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/.github/workflows/send-docs-redirects-to-staging.yml b/.github/workflows/send-docs-redirects-to-staging.yml index f8bc78c24..96798ca3c 100644 --- a/.github/workflows/send-docs-redirects-to-staging.yml +++ b/.github/workflows/send-docs-redirects-to-staging.yml @@ -41,6 +41,23 @@ jobs: role-to-assume: ${{ secrets.AWS_ADMIN_GITHUB_OIDC_ROLE_ARN_DOCS }} aws-region: us-east-1 + - name: Check website redirects format + run: | + INVALID_REDIRECTS=$(grep -P 'website_redirect\s*=\s*"[^/h]|website_redirect\s*=\s*"h(?!ttps?://)' variables.tf || true) + if [ ! -z "$INVALID_REDIRECTS" ]; then + echo "❌ Error: Found website_redirect entries with invalid format:" + echo "----------------------------------------" + echo "$INVALID_REDIRECTS" | while read -r line; do + echo -e "\033[31m$line\033[0m" + done + echo "----------------------------------------" + echo "website_redirect must start with either '/' or 'http'" + echo "Examples:" + echo " website_redirect = \"/home.html\"" + echo " website_redirect = \"https://example.com\"" + exit 1 + fi + - name: Terraform Format if: ${{ github.event_name == 'pull_request' }} id: fmt diff --git a/.github/workflows/send-enterprise-redirects-to-staging.yml b/.github/workflows/send-enterprise-redirects-to-staging.yml index 01881aa9c..affc1e29e 100644 --- a/.github/workflows/send-enterprise-redirects-to-staging.yml +++ b/.github/workflows/send-enterprise-redirects-to-staging.yml @@ -38,6 +38,23 @@ jobs: role-to-assume: ${{ secrets.AWS_ADMIN_GITHUB_OIDC_ROLE_ARN_DOCS }} aws-region: us-east-1 + - name: Check website redirects format + run: | + INVALID_REDIRECTS=$(grep -P 'website_redirect\s*=\s*"[^/h]|website_redirect\s*=\s*"h(?!ttps?://)' variables.tf || true) + if [ ! -z "$INVALID_REDIRECTS" ]; then + echo "❌ Error: Found website_redirect entries with invalid format:" + echo "----------------------------------------" + echo "$INVALID_REDIRECTS" | while read -r line; do + echo -e "\033[31m$line\033[0m" + done + echo "----------------------------------------" + echo "website_redirect must start with either '/' or 'http'" + echo "Examples:" + echo " website_redirect = \"/home.html\"" + echo " website_redirect = \"https://example.com\"" + exit 1 + fi + - name: Terraform Format if: ${{ github.event_name == 'pull_request' }} id: fmt