-
Notifications
You must be signed in to change notification settings - Fork 3
43 lines (36 loc) · 1.39 KB
/
main.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
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