-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (47 loc) · 1.52 KB
/
sync.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
50
51
name: Sync with Api
on:
schedule:
- cron: '0 */12 * * *'
jobs:
fetch-content:
if: github.repository == 'aghontpi/mirror-xkcd-api'
name: execute python logic
runs-on: ubuntu-latest
env:
new_content: true
steps:
- uses: actions/checkout@v1
- name: install requests pip3
run: pip3 install requests
- name: run python logic
run: python3 ./sync.py
- name: status of the new folder
run: git status api/ --porcelain
- name: add new files
run: |
git config --local user.name "sync bot"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add *
- name: commit new content
id: newfiles
run: (awk '{print "added content " substr($3, match($3,"\""), match($3,"}")-1) "."}' syncState.json) | git commit -F -
continue-on-error: true
- name: not proceed if there is no new files
if: steps.newfiles.outcome == 'failure' && env.new_content == 'true'
run: |
echo "no new content was fetched"
echo "new_content=false" >> $GITHUB_ENV
- name: push the new content
if: env.new_content == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN }}
branch: main
# debug
# on:
# push:
# branches:
# - master
# on:
# schedule:
# - cron: '0 */12 * * *'