wip
This commit is contained in:
@@ -3,6 +3,10 @@ name: BuildApp
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: build-${{ github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-frontend:
|
build-frontend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -110,82 +114,47 @@ 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
|
||||||
publish-build:
|
run: |
|
||||||
|
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:
|
||||||
- uses: https://github.com/actions/checkout@v4
|
- name: Download frontend artifacts
|
||||||
|
|
||||||
- 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: ./release/frontend
|
path: frontend
|
||||||
|
|
||||||
- name: Download backend
|
- name: Download webapi artifacts
|
||||||
uses: https://github.com/actions/download-artifact@v3
|
uses: https://github.com/actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: webapi
|
name: webapi
|
||||||
path: ./release/webapi
|
path: webapi
|
||||||
|
|
||||||
- name: Zip artifacts
|
- name: Store artifacts locally on runner
|
||||||
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:
|
||||||
API: "https://code.bim-it.pl/api/v1"
|
BUILD_DIR: /runner-cache/builds/${{ github.run_id }}
|
||||||
OWNER: "${{ github.repository_owner }}"
|
|
||||||
REPO: "${{ github.event.repository.name }}"
|
|
||||||
TOKEN: "${{ secrets.GITEATOKEN }}"
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
TAG="build-main-latest"
|
mkdir -p "$BUILD_DIR"
|
||||||
# spróbuj pobrać release po tagu
|
cp -r webapi "$BUILD_DIR/"
|
||||||
if curl -sfSL -H "Authorization: token $TOKEN" "$API/repos/$OWNER/$REPO/releases/tags/$TAG" -o rel.json; then
|
cp -r frontend "$BUILD_DIR/"
|
||||||
ID=$(jq -r '.id' rel.json)
|
mkdir -p /runner-cache/builds
|
||||||
else
|
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest
|
||||||
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
|
{
|
||||||
env:
|
echo "BUILD_TIME=$(date -Iseconds)"
|
||||||
API: "https://code.bim-it.pl/api/v1"
|
echo "COMMIT_SHA=${GITHUB_SHA}"
|
||||||
OWNER: "${{ github.repository_owner }}"
|
echo "BRANCH=${GITHUB_REF_NAME}"
|
||||||
REPO: "${{ github.event.repository.name }}"
|
echo "BUILD_ID=${GITHUB_RUN_ID}"
|
||||||
TOKEN: "${{ secrets.GITEATOKEN }}"
|
} > "$BUILD_DIR/build-info.txt"
|
||||||
RID: "${{ steps.rel.outputs.id }}"
|
|
||||||
run: |
|
echo "Build artifacts stored in: $BUILD_DIR"
|
||||||
set -euo pipefail
|
ls -la "$BUILD_DIR/"
|
||||||
upload () {
|
echo "Symlink 'latest' -> $(readlink -f /runner-cache/builds/latest)"
|
||||||
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"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user