bing_image #1375
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |