Skip to content

wip

wip #1

name: Deploy Web Application
on:
push:
branches:
- main
jobs:
trigger-build:
runs-on: ubuntu-latest
steps:
- name: Trigger build in Repo A
id: trigger-build
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/lingo-db/lingo-db/actions/workflows/release-for-webinterface.yml/dispatches \
-d '{"ref":"b0d8f7a"}'
- name: Wait for a few seconds
run: sleep 5
- name: Get workflow run ID
id: get-run-id
run: |
run_id=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/lingo-db/lingo-db/actions/workflows/release-for-webinterface.yml/runs \
| jq -r '.workflow_runs[0].id')
echo "::set-output name=run_id::$run_id"
wait-for-build:
runs-on: ubuntu-latest
needs: trigger-build
steps:
- name: Wait for build completion
id: wait-for-build
run: |
while true; do
status=$(curl -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }} \
| jq -r '.status')
if [ "$status" == "completed" ]; then
conclusion=$(curl -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }} \
| jq -r '.conclusion')
if [ "$conclusion" == "success" ]; then
echo "Build completed successfully."
break
else
echo "Build failed."
exit 1
fi
else
echo "Build in progress..."
sleep 30
fi
done
- name: List artifacts from specific run in Repo A
id: list-artifacts
run: |
artifacts=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }}/artifacts)
echo "$artifacts" > artifacts.json
- name: Extract artifact URL
id: extract-url
run: |
artifact_url=$(jq -r '.artifacts[0].archive_download_url' artifacts.json)
echo "::set-output name=url::$artifact_url"
- name: Download artifacts from Repo A
run: |
curl -L -o artifacts.zip -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
${{ steps.extract-url.outputs.url }}
unzip artifacts.zip -d ./artifacts