Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP/POC/ci: trigger playwright workflow on another repo #128

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all 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
54 changes: 54 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build, Test, and Deploy

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -41,6 +42,59 @@ jobs:
env:
CI: true

- name: Trigger Repository Siemens Datatable Workflow
if: always() # Runs even if Test step fails
env:
PAT: ${{ secrets.PLAYWRIGHT }}
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $PAT" \
https://api.github.com/repos/chintankavathia/siemens-datatable/actions/workflows/test_and_deploy.yml/dispatches \
-d '{"ref":"main"}'

- name: Wait for Repository Siemens Datatable Workflow Completion
id: wait_workflow
env:
PAT: ${{ secrets.PLAYWRIGHT }}
run: |
STATUS="in_progress"
CHECK_INTERVAL=30
RUN_ID=""
echo "Polling for workflow status..."

while [ "$STATUS" = "in_progress" ] || [ "$STATUS" = "queued" ]; do
sleep $CHECK_INTERVAL

echo "Polling for workflow status...$STATUS"

# Fetch latest workflow runs for Repository B
RESPONSE=$(curl -s -H "Authorization: token $PAT" \
"https://api.github.com/repos/chintankavathia/siemens-datatable/actions/runs?branch=main&status=in_progress")

echo "Raw API Response: $RESPONSE"

RUN_ID=$(echo $RESPONSE | jq -r '.workflow_runs[0].id')
STATUS=$(echo $RESPONSE | jq -r '.workflow_runs[0].status')
done

echo "Polling for workflow status...$STATUS"

if [ "$STATUS" != "completed" ]; then
echo "Repository Siemens Datatable workflow failed or was cancelled"
exit 1
fi

CONCLUSION=$(curl -s -H "Authorization: token $PAT" \
"https://api.github.com/repos/chintankavathia/siemens-datatable/actions/runs/$RUN_ID" | jq -r '.conclusion')

if [ "$CONCLUSION" != "success" ]; then
echo "Repository Siemens Datatable workflow failed with conclusion: $CONCLUSION"
exit 1
fi

echo "Repository Siemens Datatable workflow completed successfully"

- name: Build Docs
run: |
npm run build-docs --if-present
Expand Down
Loading