-
-
Notifications
You must be signed in to change notification settings - Fork 38
59 lines (50 loc) · 1.6 KB
/
update-theme-date.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
name: Update Theme Timestamps
on:
push:
branches:
- main
paths:
- 'themes/**'
jobs:
update-timestamp:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 2
- name: Get changes
run: git diff --name-only HEAD^1 HEAD
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Detect changed themes
id: get_changes
run: |
changed_themes=$(git diff --name-only HEAD^1 HEAD | grep '^themes/' | awk -F/ '{print $2}' | sort -u | tr '\n' ' ')
echo "CHANGED_THEMES=$changed_themes" >> $GITHUB_ENV
- name: Setup python modules
run: |
pip3 install requests
- name: Setup Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Update theme date
if: env.CHANGED_THEMES != ''
run: |
for theme in $CHANGED_THEMES; do
python3 scripts/update_theme_date.py "themes/$theme"
done
- name: Commit changes
if: env.CHANGED_THEMES != ''
run: |
for theme in $CHANGED_THEMES; do
git add "themes/$theme/theme.json"
done
git commit -m "Update \`updated at\` field for \`$CHANGED_THEMES\`"
git pull origin main --rebase --strategy-option=theirs
git push origin main