Skip to content

Commit

Permalink
Merge branch 'main' into add-guide-reports-policy-vaue-in-tbd
Browse files Browse the repository at this point in the history
  • Loading branch information
rajlearner17 authored Jan 12, 2025
2 parents c524bcd + 028f6c5 commit 5620ae3
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions .github/workflows/trigger-turbot-com.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ on:
- "main"

pull_request:
types: [opened]

env:
PREVIEW_LINK: turbot-com-git-docs-guardrails
PREVIEW_DOMAIN: turbot.vercel.app
types: [opened, synchronize]

jobs:
update:
Expand All @@ -24,28 +20,49 @@ jobs:
with:
token: ${{ secrets.GH_PAT }}
repository: turbot/turbot.com
event-type: build-guardrails-docs-preview
event-type: build-guardrails-docs-preview-test
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "ref_name": "${{ github.ref_name }}"}'


comment-link:
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
if: ${{ github.event_name == 'pull_request'}}
steps:
- name: Get the deployment details
id: get_deployment_details
if: ${{ github.event_name == 'pull_request'}}
uses: actions/github-script@v6
with:
script: |
const branchName = 'docs/guardrails/${{ github.event.pull_request.head.ref }}';
- name: Convert head branch special characters to hyphens
id: sanitize_branch
run: |
sanitized_branch=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's/[^a-zA-Z0-9]/-/g')
echo "Sanitized head branch: $sanitized_branch"
echo "::set-output name=sanitized_branch::$sanitized_branch"
const response = await fetch('https://turbot.com/api/service/deploy-details', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${{ secrets.TAILPIPE_API_KEY }}',
},
body: JSON.stringify({ branch: branchName }),
});
if (!response.ok) {
core.setOutput('foundDeployment', false);
} else {
const data = await response.json();
core.setOutput('foundDeployment', true);
core.setOutput('apiResponse', data);
}
- uses: actions/github-script@v7
- name: Add comment with preview link
uses: actions/github-script@v7
if: ${{ steps.get_deployment_details.outputs.foundDeployment == 'true' }}
with:
script: |
const apiResponse = ${{ steps.get_deployment_details.outputs.apiResponse }};
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Preview link: [https://${{ env.PREVIEW_LINK }}${{ steps.sanitize_branch.outputs.sanitized_branch }}-${{ env.PREVIEW_DOMAIN }}](https://${{ env.PREVIEW_LINK }}${{ steps.sanitize_branch.outputs.sanitized_branch }}-${{ env.PREVIEW_DOMAIN }}/)'
})
body: `### Preview Available 🚀\n\n**Commit Author:** ${apiResponse.meta.githubCommitAuthorName}\n**Commit Message:** ${apiResponse.meta.githubCommitMessage}\n\n**Preview Link:** [${apiResponse.meta.branchAlias}](https://${apiResponse.meta.branchAlias})`
});

0 comments on commit 5620ae3

Please sign in to comment.