Collect Bing.com daily images #1350
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: Collect Bing.com daily images | |
on: | |
schedule: | |
- cron: '0 1 * * *' | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# 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@v2 | |
- name: Download image | |
run: | | |
tail=`curl "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1" | grep -oP "th\?id=.*?jpg"` | |
image_name=`echo $tail | grep -oP 'OHR\.\K([a-zA-Z]+)'` | |
wget -O "images/${image_name}.jpg" https://bing.com/${tail} | |
- name: Upadte README | |
run: | | |
image=`ls -t images/*.jpg | head -1` | |
echo latest image is $image | |
sed -i "s/last update:.*/last update:`date +"%F %H:%M:%S"` UTC/g" README.md | |
sed -i "s#\!\[\](images/.*)#\!\[\]($image)#g" README.md | |
- name: Commit | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git status | |
git add images/*.jpg README.md | |
git commit -m "auto commit from github actions" | |
- name: Push | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: master |