-
Notifications
You must be signed in to change notification settings - Fork 11
64 lines (54 loc) · 2.36 KB
/
check-versions.yml
File metadata and controls
64 lines (54 loc) · 2.36 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
name: Update App Versions
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
update_versions:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run update versions script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x .github/scripts/update_versions.sh
bash .github/scripts/update_versions.sh
- name: Check for changes
id: check_changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push if changed
if: steps.check_changes.outputs.changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "GitHub Action"
if [ -f updated_apps.txt ]; then
APPS_LIST=$(sed 's/^- //' updated_apps.txt | awk -F':' '{print $1}' | paste -sd ", " -)
echo "Update: $APPS_LIST" > .git/commit_msg.txt
echo "" >> .git/commit_msg.txt
cat updated_apps.txt >> .git/commit_msg.txt
rm updated_apps.txt
else
echo "Update app versions with latest releases from GitHub" > .git/commit_msg.txt
fi
git add -A
git commit -F .git/commit_msg.txt
git push origin HEAD:${GITHUB_REF#refs/heads/}
- name: Trigger update-metadata workflow
if: steps.check_changes.outputs.changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -X POST -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/update-metadata.yml/dispatches \
-d '{"ref": "${{ github.ref }}"}'