-
Notifications
You must be signed in to change notification settings - Fork 10
113 lines (90 loc) · 3.78 KB
/
update-tabi.yml
File metadata and controls
113 lines (90 loc) · 3.78 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Update tabi theme
on:
workflow_dispatch:
schedule:
- cron: "5 0 * * 1" # Weekly on Mondays at 5 past midnight UTC
jobs:
update-tabi:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Check for updates
id: check
run: |
cd themes/tabi
CURRENT=$(git rev-parse HEAD)
git fetch
git checkout origin/main
NEW=$(git rev-parse HEAD)
if [ "$CURRENT" != "$NEW" ]; then
# Get main changelog
MAIN_CHANGELOG=$(git log --pretty=format:'- %s [%h](https://github.com/welpo/tabi/commit/%H)' $CURRENT..$NEW | \
grep -v -E '^- .*(misc|misc\([^)]+\)):' | \
sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/welpo\/tabi\/pull\/\1)/g')
# Get misc changelog
MISC_CHANGELOG=$(git log --pretty=format:'- %s [%h](https://github.com/welpo/tabi/commit/%H)' $CURRENT..$NEW | \
grep -E '^- .*(misc|misc\([^)]+\)):' | \
sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/welpo\/tabi\/pull\/\1)/g')
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "old_version=${CURRENT:0:7}" >> "$GITHUB_OUTPUT"
echo "new_version=${NEW:0:7}" >> "$GITHUB_OUTPUT"
echo "main_changelog<<CHANGELOG_DELIMITER" >> "$GITHUB_OUTPUT"
echo "$MAIN_CHANGELOG" >> "$GITHUB_OUTPUT"
echo "CHANGELOG_DELIMITER" >> "$GITHUB_OUTPUT"
echo "misc_changelog<<MISC_DELIMITER" >> "$GITHUB_OUTPUT"
echo "$MISC_CHANGELOG" >> "$GITHUB_OUTPUT"
echo "MISC_DELIMITER" >> "$GITHUB_OUTPUT"
fi
cd ../..
- name: Create Pull Request
if: steps.check.outputs.has_changes == 'true'
run: |
# Create branch
BRANCH="update-tabi-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH"
# Commit changes
git add themes/tabi
git commit -m "⬆️ Update tabi
From: ${{ steps.check.outputs.old_version }}
To: ${{ steps.check.outputs.new_version }}
Update tabi to the latest version from https://github.com/welpo/tabi"
git push origin "$BRANCH"
# Write PR body to file
cat > pr_body.md << 'EOF'
## Changes in this update
Updating `themes/tabi` from [`${{ steps.check.outputs.old_version }}`](https://github.com/welpo/tabi/commit/${{ steps.check.outputs.old_version }}) to [`${{ steps.check.outputs.new_version }}`](https://github.com/welpo/tabi/commit/${{ steps.check.outputs.new_version }}).
### Changelog
${{ steps.check.outputs.main_changelog }}
EOF
if [ ! -z "${{ steps.check.outputs.misc_changelog }}" ]; then
cat >> pr_body.md << 'EOF'
<details>
<summary>Show/hide miscellaneous changes</summary>
${{ steps.check.outputs.misc_changelog }}
</details>
EOF
fi
# Add footer
cat >> pr_body.md << 'EOF'
---
Auto-generated by the "Update tabi theme" workflow (in `.github/workflows/update-tabi.yml`).
EOF
gh pr create \
--head "$BRANCH" \
--title "⬆️ Update tabi theme to ${{ steps.check.outputs.new_version }}" \
--body-file pr_body.md
rm pr_body.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}