diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 18102653372a8..9664bb68a8f9e 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -3,6 +3,9 @@ (?:^|/)(?i)LICEN[CS]E (?:^|/)3rdparty/ (?:^|/)amplify\.yml$ +(?:^|/)build_preview_sites\.yml$ +(?:^|/)create_preview_sites\.yml$ +(?:^|/)preview_site_trigger\.yml$ (?:^|/)go\.sum$ (?:^|/)package(?:-lock|)\.json$ (?:^|/)Pipfile$ diff --git a/.github/workflows/build_preview_sites.yml b/.github/workflows/build_preview_sites.yml new file mode 100644 index 0000000000000..08a1a6dfdbdee --- /dev/null +++ b/.github/workflows/build_preview_sites.yml @@ -0,0 +1,26 @@ +name: Deploy Vector Preview Sites + +on: + workflow_run: + workflows: ["Call Build Preview"] + types: + - completed + +jobs: + deploy_vector_preview_site: + uses: ./.github/workflows/create_preview_sites.yml + with: + APP_ID: "d1a7j77663uxsc" + APP_NAME: "vector.dev" + + deploy_rust_doc_preview_site: + uses: ./.github/workflows/create_preview_sites.yml + with: + APP_ID: "d1hoyoksbulg25" + APP_NAME: "Rust Doc" + + deploy_vrl_playground_preview_site: + uses: ./.github/workflows/create_preview_sites.yml + with: + APP_ID: "d2lr4eds605rpz" + APP_NAME: "VRL Playground" diff --git a/.github/workflows/create_preview_sites.yml b/.github/workflows/create_preview_sites.yml new file mode 100644 index 0000000000000..8c3b500fb5687 --- /dev/null +++ b/.github/workflows/create_preview_sites.yml @@ -0,0 +1,88 @@ +name: Create Preview Sites + +on: + workflow_call: + inputs: + APP_ID: + description: "App ID for the associated website" + required: true + type: string + APP_NAME: + description: "Application name for the comment" + required: true + type: string + +jobs: + create_preview_site: + runs-on: ubuntu-latest + steps: + + # Get the artifacts with the PR number and branch name + - name: Download artifact + uses: actions/github-script@v3.1.0 + with: + script: | + const fs = require('fs'); + const artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0]; + const download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + fs.writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data)); + + # Extract the info from the artifact and set variables + - name: Extract PR info from artifact + run: | + unzip pr.zip -d pr + BRANCH_NAME=$(cat ./pr/PR_INFO | grep 'Branch Name' | cut -d ':' -f 2 | xargs) + SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[\/\.]/-/g') + echo "SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV + + # Kick off the job in amplify + - name: Deploy Site + env: + REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }} + REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }} + ENDPOINT: ${{ secrets.BUILDER_ENDPOINT }} + run: | + HMAC_KEY=$(echo -n $REQUEST_MESSAGE | openssl dgst -sha256 -hmac "$REQUEST_TOKEN" -binary | od -An -tx1 | tr -d ' \n'; echo) + SIGNATURE="sha256=$HMAC_KEY" + RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -H "X-Hub-Signature: $SIGNATURE" \ + -d "{\"app_id\": \"$APP_ID\", \"branch_name\": \"$SANITIZED_BRANCH_NAME\"}" \ + "$ENDPOINT") + + # check the response code and fail if not 200 + if [ "$RESPONSE_CODE" != "200" ]; then + echo "Request failed with response code $RESPONSE_CODE" + exit 1 + fi + + # Add preview link to comment if all 3 sites successfully start + - name: Comment Preview Link + if: success() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/github-script@v3 + with: + script: | + const prInfo = fs.readFileSync('./pr/PR_INFO', 'utf8'); + const prInfoLines = prInfo.split('\n'); + const issueNumber = parseInt(prInfoLines[0].split(': ')[1]); + + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: `Your preview site for the **${APP_NAME}** will be ready in a few minutes, please allow time for it to build. \n \n Heres your preview link: \n [${APP_NAME} preview](https://${SANITIZED_BRANCH_NAME}.${APP_ID}.amplifyapp.com)` + }); + + diff --git a/.github/workflows/preview_site_trigger.yml b/.github/workflows/preview_site_trigger.yml new file mode 100644 index 0000000000000..b89fe9273973a --- /dev/null +++ b/.github/workflows/preview_site_trigger.yml @@ -0,0 +1,27 @@ +name: Call Build Preview + +on: + pull_request: + types: [opened, reopened] + +jobs: + approval_check: + runs-on: ubuntu-latest + steps: + - name: Echo approval + run: | + echo "Workflow has been allowed to run for PR ${{ github.event.number }}. Setting artifacts and then continuing workflow runs" + + # Save the PR number and branch name to an artifact for use in subsequent jobs + - name: Save PR number and Branch name + run: | + mkdir -p ./pr + echo "PR Number: ${{ github.event.number }}" > ./pr/PR_INFO + echo "Branch Name: ${{ github.head_ref }}" >> ./pr/PR_INFO + + # Upload the artifact + - name: Upload PR information artifact + uses: actions/upload-artifact@v2 + with: + name: pr + path: pr/ diff --git a/lib/vector-vrl/web-playground/netlify.toml b/lib/vector-vrl/web-playground/netlify.toml deleted file mode 100644 index 824b50e04972f..0000000000000 --- a/lib/vector-vrl/web-playground/netlify.toml +++ /dev/null @@ -1,17 +0,0 @@ -# Settings in the [build] context are global and are applied to -# all contexts unless otherwise overridden by more specific contexts. -[build] - # Directory to change to before starting a build. - # This is where we will build the site in web-playground/public. - # If not set, defaults to the root directory. - base = "lib/vector-vrl/web-playground/" - - # Directory that contains the deploy-ready HTML files and - # assets generated by the build. - publish = "public/" - - # Default build command. - command = "bash ../../../scripts/ensure-wasm-pack-installed.sh && wasm-pack build --target web --out-dir public/pkg" - - # Ignore everything except the base directory and changes to vector/lib/ - ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../../lib" diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index bcf59eb205b40..0000000000000 --- a/netlify.toml +++ /dev/null @@ -1,109 +0,0 @@ -[build] -base = "website" -publish = "public" - -# Reinstate this when we figure out how to target this better -#ignore = "./scripts/build-ignore.sh" - -[build.environment] -HUGO_VERSION = "0.84.0" -ALGOLIA_INDEX_FILE="public/search.json" - -[context.production] -command = "make ci-production-build" - -[context.production.environment] -ALGOLIA_INDEX_NAME="vector_docs_prod" - -[context.deploy-preview] -command = "make ci-preview-build" - -[context.deploy-preview.environment] -ALGOLIA_INDEX_NAME="vector_docs_staging" - -[context.branch-deploy] -command = "make ci-preview-build" - -[context.branch-deploy.environment] -ALGOLIA_INDEX_NAME="vector_docs_staging" - -# Subdomain redirects -[[redirects]] -from = "https://vector-project.netlify.com/*" -to = "https://vector.dev/:splat" -status = 301 -force = true - -[[redirects]] -from = "https://calendar.vector.dev/*" -to = "https://calendar.google.com/calendar/embed?src=c_qsq1nrsgetsspkn7pjrqh6cclc%40group.calendar.google.com&ctz=America%2FNew_York" -status = 302 -force = true - -[[redirects]] -from = "https://chat.vector.dev/*" -to = "https://discord.gg/ptvgXhUF2m" -status = 302 -force = true - -[[redirects]] -from = "https://discussions.vector.dev/*" -to = "https://github.com/vectordotdev/vector/discussions" -status = 302 -force = true - -[[redirects]] -from = "https://sh.vector.dev/*" -to = "http://sh.vector.dev.s3-website-us-east-1.amazonaws.com/:splat" -status = 200 -force = true - -[[redirects]] -from = "https://test-results.vector.dev/*" -to = "http://test-results.vector.dev.s3-website-us-east-1.amazonaws.com/:splat" -status = 200 -force = true - -[[redirects]] -from = "https://rustdoc.vector.dev/*" -to = "https://vector-rustdoc.netlify.app/vector/:splat" -status = 301 -force = true - -[[redirects]] -from = "/support/" -to = "https://www.datadoghq.com/product/observability-pipelines" -status = 301 -force = true - -[[redirects]] -from = "/support-services/" -to = "https://www.datadoghq.com/product/observability-pipelines" -status = 301 -force = true - -[[redirects]] -from = "https://setup.vector.dev/*" -to = "https://s3.amazonaws.com/dd-agent/scripts/install_script_vector0.sh" -status = 302 -force = true - -# Removed pages redirects -[[redirects]] -from = "/docs/reference/configuration/field-path-notation/" -to = "/docs/reference/vrl/expressions/#path" -force = true - -# CORS headers for /index.json -[[headers]] -for = "/index.json" - -[headers.values] -Access-Control-Allow-Origin = "*" - -# Netlify plugins -[[plugins]] -package = "@netlify/plugin-lighthouse" - -[plugins.inputs] -output_path = "reports/lighthouse/index.html" diff --git a/rust-doc/netlify.toml b/rust-doc/netlify.toml deleted file mode 100644 index 345a6e7adf850..0000000000000 --- a/rust-doc/netlify.toml +++ /dev/null @@ -1,9 +0,0 @@ -[build] -publish = "../target/doc/" -command = "make docs" - -[[redirects]] -from = "/" -to = "/vector" -status = 301 -force = false diff --git a/website/Brewfile.netlify b/website/Brewfile.netlify deleted file mode 100644 index 7bad8dd1207fb..0000000000000 --- a/website/Brewfile.netlify +++ /dev/null @@ -1,2 +0,0 @@ -brew "cue" -brew "htmltest"