|
| 1 | +name: Deploy Web Application |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + trigger-build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Trigger build in Repo A |
| 14 | + id: trigger-build |
| 15 | + 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":"b0d8f7a"}' |
| 23 | +
|
| 24 | + - name: Wait for a few seconds |
| 25 | + run: sleep 5 |
| 26 | + |
| 27 | + - name: Get workflow run ID |
| 28 | + id: get-run-id |
| 29 | + 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 |
| 41 | + |
| 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." |
| 56 | + break |
| 57 | + else |
| 58 | + echo "Build failed." |
| 59 | + exit 1 |
| 60 | + 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" |
| 82 | +
|
| 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 |
0 commit comments