-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (64 loc) · 1.98 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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