CI: make source fetch robust (git if present, else API tarball fallback)
Some checks failed
Build & Release Pack / build (push) Failing after 1s
Some checks failed
Build & Release Pack / build (push) Failing after 1s
This commit is contained in:
parent
063b0f3d3d
commit
8c9fda9f8a
1 changed files with 35 additions and 2 deletions
|
|
@ -9,8 +9,41 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Environment check
|
||||||
run: git clone --branch "${GITHUB_REF_NAME}" --depth 1 "https://x-access-token:${GITHUB_TOKEN}@git.mithraic.cloud/ad3laid3/FKRPG.git" "${GITHUB_WORKSPACE}"
|
run: |
|
||||||
|
echo "cwd: $(pwd)"
|
||||||
|
echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}"
|
||||||
|
python3 --version; git --version 2>/dev/null || echo "git: MISSING"
|
||||||
|
curl --version 2>/dev/null | head -1 || echo "curl: MISSING"
|
||||||
|
tar --version 2>/dev/null | head -1 || echo "tar: MISSING"
|
||||||
|
|
||||||
|
- name: Fetch sources
|
||||||
|
run: |
|
||||||
|
if command -v git >/dev/null 2>&1; then
|
||||||
|
echo "git present -> cloning"
|
||||||
|
git clone --branch "${GITHUB_REF_NAME}" --depth 1 "https://x-access-token:${GITHUB_TOKEN}@git.mithraic.cloud/ad3laid3/FKRPG.git" "${GITHUB_WORKSPACE}"
|
||||||
|
else
|
||||||
|
echo "git missing -> downloading archive via API"
|
||||||
|
python3 - <<'PY'
|
||||||
|
import urllib.request, tarfile, io, os, shutil
|
||||||
|
ws = os.environ.get('GITHUB_WORKSPACE') or os.getcwd()
|
||||||
|
sha = os.environ['GITHUB_SHA']
|
||||||
|
token = os.environ.get('GITHUB_TOKEN', '')
|
||||||
|
url = f"https://git.mithraic.cloud/api/v1/repos/ad3laid3/FKRPG/archive/{sha}.tar.gz"
|
||||||
|
req = urllib.request.Request(url, headers={"Authorization": f"token {token}"})
|
||||||
|
raw = urllib.request.urlopen(req, timeout=120).read()
|
||||||
|
os.makedirs('/tmp/fkrpg_src', exist_ok=True)
|
||||||
|
with tarfile.open(fileobj=io.BytesIO(raw)) as tf:
|
||||||
|
tf.extractall('/tmp/fkrpg_src')
|
||||||
|
src = os.path.join('/tmp/fkrpg_src', os.listdir('/tmp/fkrpg_src')[0])
|
||||||
|
for name in os.listdir(src):
|
||||||
|
dst = os.path.join(ws, name)
|
||||||
|
if os.path.exists(dst):
|
||||||
|
shutil.rmtree(dst) if os.path.isdir(dst) else os.remove(dst)
|
||||||
|
shutil.move(os.path.join(src, name), dst)
|
||||||
|
print("Extracted sources into", ws)
|
||||||
|
PY
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Refresh index
|
- name: Refresh index
|
||||||
working-directory: client_pack
|
working-directory: client_pack
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue