name: Deploy DEV Workshop on: push: branches: - main env: STEAM_APP_ID: "107410" HOST_REPO: /home/valmo/braf HOST_CACHE: /home/valmo/braf-ci-cache/dev-workshop BRAF_CI_STAGE_DIR: dist/dev/@braf_dev jobs: deploy-dev-workshop: runs-on: ubuntu-latest steps: - name: Build changed addons and upload DEV Workshop item shell: bash env: GIT_SHA: ${{ github.sha }} GIT_BEFORE: ${{ github.event.before }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITHUB_TOKEN: ${{ github.token }} STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }} STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} STEAM_DEV_ITEM_ID: ${{ secrets.STEAM_DEV_ITEM_ID }} run: | set -euo pipefail mkdir -p "$HOST_CACHE" docker run --rm -i \ -e BRAF_CI_STAGE_DIR \ -e GIT_BEFORE \ -e GIT_SHA \ -e GITEA_TOKEN \ -e GITHUB_TOKEN \ -e HOST_CACHE \ -e HOST_REPO \ -e STEAM_APP_ID \ -e STEAM_DEV_ITEM_ID \ -e STEAM_PASSWORD \ -e STEAM_USERNAME \ -v "$HOST_REPO:/repo" \ -v "$HOST_CACHE:/cache" \ -v /var/run/docker.sock:/var/run/docker.sock \ docker.gitea.com/runner-images:ubuntu-latest \ bash -s <<'BRAF_CI' set -euo pipefail install_runtime() { export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y \ ca-certificates \ curl \ git-lfs \ libogg0 \ libuchardet0 \ libvorbis0a \ libvorbisenc2 \ libvorbisfile3 } install_mikero() { if [[ ! -x /cache/mikero-tools/bin/makepbo ]]; then rm -rf /tmp/mikero-tools-action /cache/mikero-tools mkdir -p /tmp/mikero-tools-action /cache/mikero-tools curl -fsSL \ https://github.com/arma-actions/mikero-tools/archive/refs/heads/master.tar.gz \ -o /tmp/mikero-tools-action.tar.gz tar -zxf /tmp/mikero-tools-action.tar.gz \ --strip-components=1 \ -C /tmp/mikero-tools-action tar -xf /tmp/mikero-tools-action/linux/*.tar \ --strip-components=1 \ -C /cache/mikero-tools fi export PATH="/cache/mikero-tools/bin:$PATH" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:/cache/mikero-tools/lib" } is_zero_sha() { [[ -z "${1:-}" || "$1" == "0000000000000000000000000000000000000000" ]] } addon_csv() { local IFS=, echo "$*" } configure_git_auth() { git_auth_args=() local token="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}" if [[ -n "$token" ]]; then local basic_auth basic_auth="$(printf 'x-access-token:%s' "$token" | base64 | tr -d '\n')" git_auth_args=( -c "http.https://git.valmo.dev/.extraheader=AUTHORIZATION: Basic ${basic_auth}" ) fi } git_auth() { git "${git_auth_args[@]}" "$@" } install_runtime install_mikero cd /repo git config --global --add safe.directory /repo configure_git_auth git lfs install --local git_auth fetch --no-tags origin "$GIT_SHA" || git_auth fetch --no-tags origin main if is_zero_sha "$GIT_BEFORE" || ! git cat-file -e "$GIT_BEFORE^{commit}" 2>/dev/null; then mapfile -t changed_addons < <( git ls-tree -d --name-only "$GIT_SHA" | awk '/^braf_/ {print}' | while read -r addon; do if git cat-file -e "$GIT_SHA:$addon/config.cpp" 2>/dev/null; then printf '%s\n' "$addon" fi done ) metadata_changed=true else mapfile -t changed_files < <(git diff --name-only "$GIT_BEFORE" "$GIT_SHA") mapfile -t changed_addons < <( printf '%s\n' "${changed_files[@]}" | awk -F/ '$1 ~ /^braf_/ {print $1}' | sort -u | while read -r addon; do if git cat-file -e "$GIT_SHA:$addon/config.cpp" 2>/dev/null; then printf '%s\n' "$addon" fi done ) metadata_changed=false if printf '%s\n' "${changed_files[@]}" | grep -Eq '^(mod\.cpp|meta\.cpp)$'; then metadata_changed=true fi fi if [[ "${#changed_addons[@]}" -eq 0 && "$metadata_changed" != "true" ]]; then echo "No addon or workshop metadata changes detected; skipping DEV Workshop deploy." exit 0 fi GIT_LFS_SKIP_SMUDGE=1 git reset --hard "$GIT_SHA" if [[ "${#changed_addons[@]}" -gt 0 ]]; then include="" for addon in "${changed_addons[@]}"; do include+="${include:+,}${addon}/**" done echo "Changed addons: $(addon_csv "${changed_addons[@]}")" echo "Fetching LFS only for: $include" git_auth lfs fetch origin "$GIT_SHA" --include="$include" --exclude="*" git lfs checkout "${changed_addons[@]}" else echo "Only workshop metadata changed; using cached PBOs." fi build_args=( --cache-dir /cache/pbo --stage-dir "$BRAF_CI_STAGE_DIR" --addons "$(addon_csv "${changed_addons[@]}")" ) python3 -m make.ci_dev_workshop "${build_args[@]}" short_sha="$(git rev-parse --short "$GIT_SHA")" subject="$(git log -1 --pretty=%s)" changelog="DEV ${short_sha}: ${subject}" cat > /cache/braf-dev-workshop.vdf <