diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index ea1f56e..60ebee1 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,6 +1,8 @@ name: Build packages on: + push: + branches: [main] workflow_dispatch: inputs: package: @@ -12,14 +14,25 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Detect package + id: detect + run: | + if [ -n "${{ github.event.inputs.package }}" ]; then + echo "PKG=${{ github.event.inputs.package }}" >> $GITHUB_ENV + else + PKG=$(git diff --name-only HEAD~1 HEAD | grep -oP '^[^/]+(?=/)' | sort -u | while read dir; do + [ -f "$dir/Makefile" ] && echo "$dir" + done | head -1) + echo "PKG=$PKG" >> $GITHUB_ENV + fi - name: Build and publish + if: env.PKG != '' env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | - make -C ${{ github.event.inputs.package }} \ - GITEA_USER=andrew \ - GITEA_URL=https://git.nakolenke.org \ - GITEA_ORG=nakolenke-pub \ - SUITE=trixie \ - package publish + echo "Building: $PKG" + make -C $PKG all publish