Test10 #39
Workflow file for this run
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 $files # Debugging line to check the detected files | |
echo "FILES=$files" >> $GITHUB_ENV | |
- name: Echo changed files | |
run: | | |
echo "Changed files: $FILES" | |
- name: Run Python script on changed files | |
run: | | |
IFS=$'\n' read -ra ADDR <<< "$FILES" | |
for file in "${ADDR[@]}"; do | |
echo "Processing file: $file" | |
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 | |