morska release
Some checks failed
BuildApp / build-frontend (push) Successful in 58s
BuildApp / build-backend (push) Has been cancelled

This commit is contained in:
Michał Zieliński
2025-09-12 11:27:08 +02:00
parent 4341866dcc
commit cc5ffca3aa

View File

@@ -1,7 +1,7 @@
name: Release Morska (latest successful build)
on:
workflow_dispatch: {} # ręczny trigger
workflow_dispatch: { } # ręczny trigger
env:
DEPLOY_HOST: "bim-it.pl"
@@ -9,6 +9,7 @@ env:
DEPLOY_PATH: "./deployment/"
SSH_KEYFILE: "/ci-keys/morska"
BUILD_WORKFLOW_PATH: ".gitea/workflows/build.yml"
API_BASE: "https://code.bim-it.pl/api/v1"
jobs:
release:
@@ -26,15 +27,27 @@ jobs:
- name: Resolve repo/env
id: repo
env:
GITEA_SERVER_URL: ${{ github.server_url }} # np. https://code.bim-it.pl
GITHUB_REPOSITORY: ${{ github.repository }} # owner/repo
API_BASE: ${{ env.API_BASE }}
run: |
set -euo pipefail
OWNER="${GITHUB_REPOSITORY%%/*}"
REPO="${GITHUB_REPOSITORY##*/}"
echo "owner=$OWNER" >> $GITHUB_OUTPUT
echo "repo=$REPO" >> $GITHUB_OUTPUT
echo "api=${GITEA_SERVER_URL%/}/api/v1" >> $GITHUB_OUTPUT
echo "api=$API_BASE" >> $GITHUB_OUTPUT
- name: Probe API & auth
env:
API: ${{ steps.repo.outputs.api }}
OWNER: ${{ steps.repo.outputs.owner }}
REPO: ${{ steps.repo.outputs.repo }}
TOKEN: ${{ secrets.GITEATOKEN }}
run: |
set -euo pipefail
echo "Probing: $API/repos/$OWNER/$REPO"
curl -sfSL -H "Authorization: token $TOKEN" "$API/repos/$OWNER/$REPO" >/dev/null
echo "OK"
- name: Pick latest successful build (main)
id: pick
@@ -42,13 +55,15 @@ jobs:
API: ${{ steps.repo.outputs.api }}
OWNER: ${{ steps.repo.outputs.owner }}
REPO: ${{ steps.repo.outputs.repo }}
TOKEN: ${{ secrets.GITEATOKEN }} # PAT z odczytem Actions/artefaktów w tym repo
BUILD_PATH: ${{ env.BUILD_WORKFLOW_PATH }}
TOKEN: ${{ secrets.GITEATOKEN }}
run: |
set -euo pipefail
RESP="$(curl -sfSL -H "Authorization: token $TOKEN" \
"$API/repos/$OWNER/$REPO/actions/runs?status=success&branch=main&per_page=20")"
RUN_ID="$(echo "$RESP" | jq -r --arg p "$BUILD_PATH" '
URL="$API/repos/$OWNER/$REPO/actions/runs?status=success&branch=main&per_page=20"
echo "GET $URL"
RESP="$(curl -sfSL -H "Authorization: token $TOKEN" "$URL")"
echo "$RESP" | jq -e '.workflow_runs' >/dev/null
RUN_ID="$(echo "$RESP" | jq -r '
.workflow_runs
| map(select(
(.head_branch=="main")
@@ -56,13 +71,12 @@ jobs:
and (.conclusion=="success")
and (
(.path? // .workflow_path? // .workflow?.path? // "")
| test($p + "$")
| test("(\\.gitea|\\.github)/workflows/build\\.yml$")
)
))
| sort_by(.run_number) | reverse | .[0].id // empty
')"
test -n "$RUN_ID" && echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT || { echo "No successful build found"; exit 1; }
- name: Download artifacts (frontend, webapi)
env:
API: ${{ steps.repo.outputs.api }}