-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (64 loc) · 2.25 KB
/
update-icons.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
name: Update icons
on:
workflow_dispatch:
schedule:
- cron: "0 14 15 * *" # At 14:00 on day-of-month 15 https://crontab.guru/
permissions:
contents: write
pull-requests: write
jobs:
update-icons:
name: Update icons
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if there are open PRs
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
open_prs=$(gh pr list --state open --json number --jq '. | length')
if [ "$open_prs" -gt 0 ]; then
echo "There are $open_prs open PRs, merge them before creating the update icons one"
exit 1
else
echo "No open PRs"
fi
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Prepare Git
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create branch
id: create-branch
shell: bash
run: |
timestamp=$(date +"%Y-%m-%d-%H-%M-%S")
branch_name="update-icons-$timestamp"
git checkout -b "$branch_name"
echo "branch=$branch_name" >> $GITHUB_OUTPUT
- name: Download icons
run: ./gradlew octicons:download-icons remix:download-icons tabler:download-icons feather:download-icons ionicons:download-icons fontawesome:download-icons heroicons:download-icons simpleicons:download-icons twbs:download-icons -Pgitcommit --no-parallel
- name: Create pull request
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch="${{ steps.create-branch.outputs.branch }}"
git push origin "$branch"
git fetch origin main
if git diff --quiet origin/main "$branch"; then
echo "There are no changes"
git push origin --delete "$branch"
else
echo "There are changes"
gh pr create --title "Update icons" --body "Update icons"
fi