This commit is contained in:
Michał Zieliński
2025-09-13 17:50:52 +02:00
parent d323989c0f
commit fd4e854e7c

View File

@@ -3,11 +3,6 @@ name: BuildApp
on: on:
workflow_dispatch: {} workflow_dispatch: {}
# (opcjonalnie; jeśli coś krzyczy w Twojej wersji Gitei, usuń całą sekcję concurrency)
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: false
jobs: jobs:
build-frontend: build-frontend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -115,47 +110,82 @@ jobs:
path: build/webapi path: build/webapi
if-no-files-found: error if-no-files-found: error
retention-days: 7 retention-days: 7
- name: Diagnose mounts
run: | publish-build:
set -e
mount | grep runner-cache || true
ls -la /runner-cache || true
echo "MARKER $(date -Iseconds)" | tee /runner-cache/__ok.txt
store-artifacts:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build-frontend, build-backend] needs: [build-frontend, build-backend]
if: ${{ success() }}
steps: steps:
- name: Download frontend artifacts - uses: https://github.com/actions/checkout@v4
- name: Tools
run: |
set -euo pipefail
apt-get update -y
apt-get install -y jq unzip zip curl
- name: Download frontend
uses: https://github.com/actions/download-artifact@v3 uses: https://github.com/actions/download-artifact@v3
with: with:
name: frontend name: frontend
path: frontend path: ./release/frontend
- name: Download webapi artifacts - name: Download backend
uses: https://github.com/actions/download-artifact@v3 uses: https://github.com/actions/download-artifact@v3
with: with:
name: webapi name: webapi
path: webapi path: ./release/webapi
- name: Store artifacts locally on runner - name: Zip artifacts
run: |
(cd release/frontend && zip -r ../DiunaBI-Morska-Frontend.zip .)
(cd release/webapi && zip -r ../DiunaBI-Morska-WebApi.zip .)
ls -la release
- name: Create or update release (tag build-main-latest)
id: rel
env: env:
BUILD_DIR: /runner-cache/builds/${{ github.run_id }} API: "https://code.bim-it.pl/api/v1"
OWNER: "${{ github.repository_owner }}"
REPO: "${{ github.event.repository.name }}"
TOKEN: "${{ secrets.GITEATOKEN }}"
run: | run: |
set -euo pipefail set -euo pipefail
mkdir -p "$BUILD_DIR" TAG="build-main-latest"
cp -r webapi "$BUILD_DIR/" # spróbuj pobrać release po tagu
cp -r frontend "$BUILD_DIR/" if curl -sfSL -H "Authorization: token $TOKEN" "$API/repos/$OWNER/$REPO/releases/tags/$TAG" -o rel.json; then
mkdir -p /runner-cache/builds ID=$(jq -r '.id' rel.json)
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest else
DATA=$(jq -n --arg tag "$TAG" --arg name "Latest build for main" \
--arg sha "${{ github.sha }}" '{tag_name:$tag,name:$name,target_commitish:$sha,prerelease:true,draft:false}')
curl -sfSL -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
-d "$DATA" "$API/repos/$OWNER/$REPO/releases" -o rel.json
ID=$(jq -r '.id' rel.json)
fi
echo "id=$ID" >> $GITHUB_OUTPUT
{ - name: Upload assets
echo "BUILD_TIME=$(date -Iseconds)" env:
echo "COMMIT_SHA=${GITHUB_SHA}" API: "https://code.bim-it.pl/api/v1"
echo "BRANCH=${GITHUB_REF_NAME}" OWNER: "${{ github.repository_owner }}"
echo "BUILD_ID=${GITHUB_RUN_ID}" REPO: "${{ github.event.repository.name }}"
} > "$BUILD_DIR/build-info.txt" TOKEN: "${{ secrets.GITEATOKEN }}"
RID: "${{ steps.rel.outputs.id }}"
echo "Build artifacts stored in: $BUILD_DIR" run: |
ls -la "$BUILD_DIR/" set -euo pipefail
echo "Symlink 'latest' -> $(readlink -f /runner-cache/builds/latest)" upload () {
local file="$1" name="$2"
# usuń asset o tej nazwie jeśli istnieje (unikniemy duplikatów)
curl -sfSL -H "Authorization: token $TOKEN" "$API/repos/$OWNER/$REPO/releases/$RID/assets" -o assets.json
OLD_ID=$(jq -r --arg n "$name" '.[] | select(.name==$n) | .id' assets.json)
if [ -n "$OLD_ID" ] && [ "$OLD_ID" != "null" ]; then
curl -sfSL -X DELETE -H "Authorization: token $TOKEN" \
"$API/repos/$OWNER/$REPO/releases/$RID/assets/$OLD_ID" >/dev/null || true
fi
# wgraj nowy plik
curl -sfSL -H "Authorization: token $TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@${file}" \
"$API/repos/$OWNER/$REPO/releases/$RID/assets?name=${name}" >/dev/null
}
upload "release/DiunaBI-Morska-Frontend.zip" "DiunaBI-Morska-Frontend.zip"
upload "release/DiunaBI-Morska-WebApi.zip" "DiunaBI-Morska-WebApi.zip"