update build
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
name: BuildApp
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
# push:
|
||||
# branches: [ main ]
|
||||
# pull_request:
|
||||
#branches: [ main ]
|
||||
workflow_dispatch: {}
|
||||
|
||||
# (opcjonalnie) ogranicz równoległe runy
|
||||
@@ -123,3 +123,70 @@ jobs:
|
||||
path: build/webapi
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
publish-build:
|
||||
needs: [ build-frontend, build-backend ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: Tools
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y jq unzip zip curl
|
||||
|
||||
- name: Download frontend
|
||||
uses: https://github.com/actions/download-artifact@v3
|
||||
with: { name: frontend, path: ./release/frontend }
|
||||
|
||||
- name: Download backend
|
||||
uses: https://github.com/actions/download-artifact@v3
|
||||
with: { name: webapi, path: ./release/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
|
||||
env:
|
||||
API: "${{ github.server_url }}/api/v1"
|
||||
OWNER: "${{ github.repository_owner }}"
|
||||
REPO: "${{ github.event.repository.name }}"
|
||||
TOKEN: "${{ secrets.GITEATOKEN }}"
|
||||
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
|
||||
# utwórz release
|
||||
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 to release
|
||||
env:
|
||||
API: "${{ github.server_url }}/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"
|
||||
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