-
Notifications
You must be signed in to change notification settings - Fork 208
/
update_apps_raspbian_addons.yml.disabled
94 lines (79 loc) · 3.51 KB
/
update_apps_raspbian_addons.yml.disabled
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
name: Update_Raspbian_Addons_apps
# Controls when the workflow will run
on:
# run every hour
schedule:
- cron: 5 * * * *
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
update-raspbian-addons:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a set of commands using the runners shell
- name: Run app update scripts
run: |
#source pi-apps functions
#export all functions and variables
set -a
#make DIRECTORY equal to GITHUB_WORKSPACE, for subscripts and api functions
DIRECTORY=$GITHUB_WORKSPACE
source $GITHUB_WORKSPACE/api
#add special functions
get_release() {
curl -s --header "Authorization: token ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}" "https://api.github.com/repos/$1/releases/latest" | jq -r '.tag_name' | sed s/v//g
}
get_prerelease() {
curl -s --header "Authorization: token ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}" "https://api.github.com/repos/$1/releases" | jq -r 'map(select(.prerelease)) | first | .tag_name' | sed s/v//g
}
function validate_url(){
if command wget --timeout=5 --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36" -q --spider "$1"; then
return 0
else
return 1
fi
}
#stop exporting functions
set +a
#make sure all update scripts are executable
chmod +x $GITHUB_WORKSPACE/.github/workflows/updates/*.sh
cd $GITHUB_WORKSPACE
apps=( .github/workflows/updates/*.sh )
for app_directory in "${apps[@]}"; do
# make sure we are still in the main workspace (incase an update script left off elsewhere)
cd $GITHUB_WORKSPACE
# check if this is a raspbian addons application by checking for string https://apt.raspbian-addons.org
if grep -q "https://apt.raspbian-addons.org" "$app_directory"; then
export app_name="$(echo ${app_directory%.*} | sed 's:.*/::')"
echo "$app_name"
status "Checking $app_name for updates from apt.raspbian-addons.org"
# move to app folder
cd "$GITHUB_WORKSPACE/apps/$app_name"
# run app update script
"$GITHUB_WORKSPACE/$app_directory"
fi
done
cd
if test -f /tmp/updated_apps; then
sort -u /tmp/updated_apps > /tmp/updated_apps_sorted
echo "UPDATED_APPS<<EOF" >> $GITHUB_ENV
cat /tmp/updated_apps_sorted >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
if test -f /tmp/failed_apps; then
echo "FAILED_APPS<<EOF" >> $GITHUB_ENV
cat /tmp/failed_apps | sed '0~1 a\\' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Push any changes to repo
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: |
Update App Versions, run by GitHub Actions - Apps updated:
${{ env.UPDATED_APPS }}