Changes detected! #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Changes detected! | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
- 'refre.sh' | |
- 'renovate.json' | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronized | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
- 'refre.sh' | |
- 'renovate.json' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
find_changes: | |
name: Find Changes | |
runs-on: ubuntu-latest | |
container: archlinux:base-devel | |
timeout-minutes: 5 | |
outputs: | |
list: ${{ steps.changes.outputs.changed_pkgs }} | |
steps: | |
- name: Update system and install dependencies | |
run: | | |
pacman-key --init | |
pacman -Syu --noconfirm git jq | |
- name: Find Changes | |
id: changes | |
run: | | |
if [ ${{ github.event_name }} == 'push' ] | |
then | |
CHANGED_DIRS=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep PKGBUILD | cut -d / -f 1) | |
fi | |
elif [ ${github.event_name} == 'pull_request' ] | |
then | |
CHANGED_DIRS=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | cut -d / -f 1) | |
fi | |
# Remove .github from CHANGED_DIRS | |
FINAL_CHANGED_DIRS=() | |
for dir in $(echo $CHANGED_DIRS | sed "s|.github||") | |
do | |
FINAL_CHANGED_DIRS+=('$dir') | |
done | |
# Set output | |
echo "changed_pkgs=$(jq -cn '$ARGS.positional' --args "${FINAL_CHANGED_DIRS[@]}")" >> $GITHUB_OUTPUT | |
build: | |
name: Build | |
needs: find_changes | |
uses: ./.github/workflows/build.yml | |
with: | |
packages: needs.find_changes.outputs.list |