github actions: introduce workflow_dispatch trigger for rebuilding packages

This commit is contained in:
Leonid Pliushch 2021-10-26 20:19:10 +03:00
parent 1699781478
commit 3194a85278
No known key found for this signature in database
GPG Key ID: 45F2964132545795
1 changed files with 72 additions and 59 deletions

View File

@ -9,6 +9,11 @@ on:
pull_request:
paths:
- 'packages/**'
workflow_dispatch:
inputs:
packages:
description: "A space-separated names of packages selected for rebuilding"
required: true
jobs:
build:
@ -27,6 +32,7 @@ jobs:
fetch-depth: 1000
- name: Build
run: |
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
BASE_COMMIT=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
OLD_COMMIT=$(jq --raw-output .commits[0].id "$GITHUB_EVENT_PATH")
HEAD_COMMIT=$(jq --raw-output .commits[-1].id "$GITHUB_EVENT_PATH")
@ -46,8 +52,10 @@ jobs:
echo "Processing pull request #$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH"): ${BASE_COMMIT}..HEAD"
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "${BASE_COMMIT}" "HEAD")
fi
fi
mkdir -p ./artifacts ./debs
touch ./debs/.placeholder
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
# Process tag '%ci:no-build' that may be added as line to commit message.
# Forces CI to cancel current build with status 'passed'.
if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 "HEAD"); then
@ -93,6 +101,11 @@ jobs:
fi
fi
done<<<${CHANGED_FILES}
else
for i in ${{ github.event.inputs.packages }}; do
echo "$i" >> ./built_packages.txt
done
fi
# Fix so that lists do not contain duplicates
if [ -f ./built_packages.txt ]; then