Skip to content

Commit d413d46

Browse files
committed
wip
1 parent eae58e3 commit d413d46

File tree

1 file changed

+53
-61
lines changed

1 file changed

+53
-61
lines changed

.github/workflows/build-interface.yml

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,78 +10,70 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13+
- name: Authenticate GitHub CLI
14+
run: echo "${{ secrets.LINGODB_TOKEN }}" | gh auth login --with-token
1315
- name: Trigger build in Repo A
1416
id: trigger-build
1517
run: |
16-
curl -L \
17-
-X POST \
18-
-H "Accept: application/vnd.github+json" \
19-
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
20-
-H "X-GitHub-Api-Version: 2022-11-28" \
21-
https://api.github.com/repos/lingo-db/lingo-db/actions/workflows/release-for-webinterface.yml/dispatches \
22-
-d '{"ref":"webinterface-build"}'
18+
gh api repos/lingo-db/lingodb-test-actions/actions/workflows/release-for-webinterface.yml/dispatches -F ref="main" -F inputs[ref]="b0d8f7a6f5be75a1b545ac54764473048f36b5d7"
2319
2420
- name: Wait for a few seconds
2521
run: sleep 5
2622

2723
- name: Get workflow run ID
2824
id: get-run-id
2925
run: |
30-
run_id=$(curl -L \
31-
-H "Accept: application/vnd.github+json" \
32-
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
33-
-H "X-GitHub-Api-Version: 2022-11-28" \
34-
https://api.github.com/repos/lingo-db/lingo-db/actions/workflows/release-for-webinterface.yml/runs \
35-
| jq -r '.workflow_runs[0].id')
36-
echo "::set-output name=run_id::$run_id"
37-
38-
wait-for-build:
39-
runs-on: ubuntu-latest
40-
needs: trigger-build
26+
run_id=$(gh api repos/lingo-db/lingodb-test-actions/actions/workflows/release-for-webinterface.yml/runs | jq -r '.workflow_runs[0].id')
27+
echo "build_run_id=$(run_id)" >> $GITHUB_OUTPUT
28+
- name: Get Workflow Run Status and Wait
29+
id: wait-for-run
30+
run: |
31+
build_run_id="${{ steps.get-run-id.outputs.build_run_id }}"
32+
33+
echo "Checking status of workflow run with ID $build_run_id"
34+
35+
while :; do
36+
status=$(gh api \
37+
repos/lingo-db/lingodb-test-actions/actions/runs/$build_run_id \
38+
--jq '.status')
39+
40+
echo "Current status: $status"
41+
42+
if [[ "$status" == "completed" ]]; then
43+
conclusion=$(gh api \
44+
repos/lingo-db/lingodb-test-actions/actions/runs/$build_run_id \
45+
--jq '.conclusion')
46+
47+
echo "Workflow completed with conclusion: $conclusion"
48+
49+
if [[ "$conclusion" != "success" ]]; then
50+
echo "Workflow did not succeed. Failing current workflow."
51+
exit 1
52+
fi
4153
42-
steps:
43-
- name: Wait for build completion
44-
id: wait-for-build
45-
run: |
46-
while true; do
47-
status=$(curl -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
48-
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }} \
49-
| jq -r '.status')
50-
if [ "$status" == "completed" ]; then
51-
conclusion=$(curl -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
52-
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }} \
53-
| jq -r '.conclusion')
54-
if [ "$conclusion" == "success" ]; then
55-
echo "Build completed successfully."
5654
break
57-
else
58-
echo "Build failed."
59-
exit 1
6055
fi
61-
else
62-
echo "Build in progress..."
63-
sleep 30
64-
fi
65-
done
66-
67-
- name: List artifacts from specific run in Repo A
68-
id: list-artifacts
69-
run: |
70-
artifacts=$(curl -L \
71-
-H "Accept: application/vnd.github+json" \
72-
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
73-
-H "X-GitHub-Api-Version: 2022-11-28" \
74-
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }}/artifacts)
75-
echo "$artifacts" > artifacts.json
76-
77-
- name: Extract artifact URL
78-
id: extract-url
79-
run: |
80-
artifact_url=$(jq -r '.artifacts[0].archive_download_url' artifacts.json)
81-
echo "::set-output name=url::$artifact_url"
8256
83-
- name: Download artifacts from Repo A
84-
run: |
85-
curl -L -o artifacts.zip -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
86-
${{ steps.extract-url.outputs.url }}
87-
unzip artifacts.zip -d ./artifacts
57+
echo "Waiting for 10 seconds before checking again..."
58+
sleep 10
59+
done
60+
61+
- name: Download and Extract Artifact
62+
run: |
63+
build_run_id="${{ steps.get-run-id.outputs.build_run_id }}"
64+
65+
echo "Fetching artifact for workflow run ID $build_run_id"
66+
67+
artifact_id=$(gh api \
68+
repos/lingo-db/lingodb-test-actions/actions/runs/$build_run_id/artifacts \
69+
--jq '.artifacts[0].id')
70+
71+
echo "Artifact ID: $artifact_id"
72+
73+
gh api \
74+
repos/lingo-db/lingodb-test-actions/actions/artifacts/$artifact_id/zip > artifact.zip
75+
76+
mkdir -p docker-build
77+
unzip artifact.zip -d docker-build
78+
79+
echo "Artifact extracted to docker-build directory."

0 commit comments

Comments
 (0)