Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
(?:^|/)(?i)LICEN[CS]E
(?:^|/)3rdparty/
(?:^|/)amplify\.yml$
(?:^|/)build_preview_sites\.yml$
(?:^|/)create_preview_sites\.yml$
(?:^|/)go\.sum$
(?:^|/)package(?:-lock|)\.json$
(?:^|/)Pipfile$
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/build_preview_sites.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy Vector Preview Sites

on:
workflow_run:
workflows: ["Call Preview Build"]
types:
- completed

jobs:
deploy_vecotr_preview_site:
Comment thread
devindford marked this conversation as resolved.
Outdated
uses: ./.github/workflows/create_preview_sites.yml@master
with:
APP_ID: "d1a7j77663uxsc"
APP_NAME: "vector.dev"

deploy_rust_doc_preview_site:
uses: ./.github/workflows/create_preview_sites.yml@master
with:
APP_ID: "d1hoyoksbulg25"
APP_NAME: "Rust Doc"

deploy_vrl_playground_preview_site:
uses: ./.github/workflows/create_preview_sites.yml@master
with:
APP_ID: "d2lr4eds605rpz"
APP_NAME: "VRL Playground"
43 changes: 43 additions & 0 deletions .github/workflows/create_preview_sites.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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:
- name: Deploy Site
run: |
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\": \"${{ github.head_ref }}\"}" \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will github.head_ref work here? I'm not actually sure what ref it might refer to in this context (maybe master?). I would think you might need to thread the PR git ref through from the "Call Build Preview" via build artifacts (similar to what is described on https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).

"$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 }}
run: |
URLIZED_BRANCH=$(echo "${{ github.head_ref }}" | tr './' '--')
Comment thread Fixed
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I don't know that github.event.pull_request.number will be populated. You may need to thread it through from the PR-triggered workflow as a build artifact.

COMMENT_CONTENT="Your preview site for the **$APP_NAME** will be ready in a few minutes, please allow time for it to build. \n \n Here's your link: \n [$APP_NAME preview](https://$URLIZED_BRANCH.$APP_ID.amplifyapp.com)"
Comment thread Fixed
Comment thread Fixed


13 changes: 13 additions & 0 deletions .github/workflows/preview_site_trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Call Build Preview

on:
pull_request:
types: [opened, reopened, syncronize]
Comment thread Fixed

jobs:
build:
runs-on: ubuntu-latest

steps:
- run: echo "Workflow has been allowed to run for PR ${{ github.event.number }}"