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