Merge pull request #3 from steveraysteveray/try8-branch #29
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: Add @base on Push | |
on: [push] | |
jobs: | |
check_commit: | |
runs-on: ubuntu-latest | |
outputs: | |
skip: ${{ steps.skip_check.outputs.skip }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- id: skip_check | |
run: | | |
MESSAGE=$(git log --format=%B -n 1) | |
if [[ "$MESSAGE" == *"[AUTO]"* ]]; then | |
echo "Commit message contains [AUTO]. Setting skip to true." | |
echo "::set-output name=skip::true" | |
else | |
echo "::set-output name=skip::false" | |
fi | |
update_ttl_files: | |
needs: check_commit | |
runs-on: ubuntu-latest | |
if: needs.check_commit.outputs.skip == 'false' | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Get changed files | |
id: getfile | |
run: | | |
files=$(git diff-tree --no-commit-id --name-only -r $(git log -n 1 --pretty=format:"%H") | grep ".ttl$" || echo "") | |
if [ -z "$files" ]; then | |
echo "No .ttl files changed." | |
exit 0 | |
fi | |
echo "::set-output name=files::$files" | |
- name: Run Python script on changed files | |
run: | | |
IFS=' ' read -ra ADDR <<< "${{ steps.getfile.outputs.files }}" | |
for file in "${ADDR[@]}"; do | |
python add-base.py "$file" | |
done | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<[email protected]>" | |
- name: Commit and Push changes | |
run: | | |
git add -u # Adds only modified files to the staging area | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit" | |
else | |
git commit -m "Updated .ttl files with base URI [AUTO]" | |
git push | |
fi | |