-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (42 loc) · 1.64 KB
/
bing_image.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
name: Bing Image
on:
repository_dispatch:
types:
- bing_image
# schedule:
# # Times are in UTC
# - cron: '0 9 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: check out repository
uses: actions/checkout@v3
- name: install apps
run: |
sudo apt-get update
sudo apt-get install -y ghostscript imagemagick
- name: download image
run: |
baseURL='https://www.bing.com'
jsonURL="${baseURL}/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-CA"
jsonData=$(curl -s "${jsonURL}")
imageURL="${baseURL}"$( echo "${jsonData}" | jq -r '.images[0].url' )
echo "${imageURL}"
imageDesc=$(echo "${jsonData}" | jq -r '.images[0].copyright')
curl -Lo homepage/images/today_clean.jpg "${imageURL}"
convert -font DejaVu-Sans -pointsize 18 -background '#00000080' -fill white label:"${imageDesc}" miff:- | \
composite -gravity south -geometry +0+60 - homepage/images/today_clean.jpg homepage/images/today.jpg
convert -quality 50 homepage/images/today.jpg homepage/images/today.avif
convert -quality 50 homepage/images/today.jpg homepage/images/today.webp
- name: update readme
run: |
sed -i "s|\(image: \).*$|\1$(date -u)|" homepage/README.md
- name: commit and push
run: |
git config --local user.email "[email protected]"
git config --local user.name "Ali Mustakim"
git add .
git diff-index --quiet HEAD || git commit -a -m "github actions update"
git push origin