This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Web Application | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| trigger-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Authenticate GitHub CLI | ||
| run: echo "${{ secrets.LINGODB_TOKEN }}" | gh auth login --with-token | ||
| - name: Trigger build in Repo A | ||
| id: trigger-build | ||
| run: | | ||
| gh api repos/lingo-db/lingodb-test-actions/actions/workflows/release-for-webinterface.yml/dispatches -F ref="main" -F inputs[ref]="b0d8f7a6f5be75a1b545ac54764473048f36b5d7" | ||
| - name: Wait for a few seconds | ||
| run: sleep 5 | ||
| - name: Get workflow run ID | ||
| id: get-run-id | ||
| run: | | ||
| run_id=$(gh api repos/lingo-db/lingodb-test-actions/actions/workflows/release-for-webinterface.yml/runs | jq -r '.workflow_runs[0].id') | ||
| echo "build_run_id=$(run_id)" >> $GITHUB_OUTPUT | ||
| - name: Get Workflow Run Status and Wait | ||
| id: wait-for-run | ||
| run: | | ||
| build_run_id="${{ steps.get-run-id.outputs.build_run_id }}" | ||
| echo "Checking status of workflow run with ID $build_run_id" | ||
| while :; do | ||
| status=$(gh api \ | ||
| repos/lingo-db/lingodb-test-actions/actions/runs/$build_run_id \ | ||
| --jq '.status') | ||
| echo "Current status: $status" | ||
| if [[ "$status" == "completed" ]]; then | ||
| conclusion=$(gh api \ | ||
| repos/lingo-db/lingodb-test-actions/actions/runs/$build_run_id \ | ||
| --jq '.conclusion') | ||
| echo "Workflow completed with conclusion: $conclusion" | ||
| if [[ "$conclusion" != "success" ]]; then | ||
| echo "Workflow did not succeed. Failing current workflow." | ||
| exit 1 | ||
| fi | ||
| break | ||
| fi | ||
| echo "Waiting for 10 seconds before checking again..." | ||
| sleep 10 | ||
| done | ||
| - name: Download and Extract Artifact | ||
| run: | | ||
| build_run_id="${{ steps.get-run-id.outputs.build_run_id }}" | ||
| echo "Fetching artifact for workflow run ID $build_run_id" | ||
| artifact_id=$(gh api \ | ||
| repos/lingo-db/lingodb-test-actions/actions/runs/$build_run_id/artifacts \ | ||
| --jq '.artifacts[0].id') | ||
| echo "Artifact ID: $artifact_id" | ||
| gh api \ | ||
| repos/lingo-db/lingodb-test-actions/actions/artifacts/$artifact_id/zip > artifact.zip | ||
| mkdir -p docker-build | ||
| unzip artifact.zip -d docker-build | ||
| echo "Artifact extracted to docker-build directory." | ||