-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (64 loc) · 3.24 KB
/
cron-6am.yaml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
## CRON JOB - daily @ 6am [UTC = GMT+0]
# NOTE: The cron job is scheduled for 7am (GMT+1) but gets queued and usually runs around 7:22am [GMT+1] (1:22am [GMT-5] in Montréal Canada, where Unsplash is located)
name: cron-6am-daily
on:
workflow_dispatch:
schedule:
# daily @ 6am UTC
- cron: '0 6 * * *'
jobs:
job1:
runs-on: ubuntu-latest
#defaults:
# run:
# shell: bash
steps:
# v1 - revalidates / /1 /2 - always successful no matter the status code etc.
#- name: Step 1/2 - Revalidate StaticProps - [[...id]].tsx
# run: |
# curl --request POST \
# --url 'https://photo-of-the-day-unsplash.vercel.app/api/revalidate/potd' \
# --header 'Authorization: Bearer ${{ secrets.GH_REPO_SECRET_KEY }}'
# v2 - revalidates / /1 /2 - checks for status-code != 200
# This puts the output in stderr and the status-code in STATUS, then adds stderr back to stdout and checks for STATUS != 200
- name: Step 1/1 - Revalidate StaticProps - [[...id]].tsx
run: |
{ STATUS=$(curl --request POST -isSL -o /dev/stderr -w "%{http_code}" --url 'https://photo-of-the-day-unsplash.vercel.app/api/revalidate/potd' --header 'Authorization: Bearer ${{ secrets.GH_REPO_SECRET_KEY }}'); } 2>&1;
echo ""
echo "Exit code: $?"
# exit 1 aborts job with an error; exit 0 means "all good, move on"
if [[ STATUS -ne 200 ]]; then exit 1; else exit 0; fi
# v1 google
#- name: Step 2/2 - Sitemap-Ping - google.com
# run: |
# curl -isSL -o /dev/null -w "%{http_code}\n" \
# --url 'https://www.google.com/ping?sitemap=https%3A%2F%2Fphoto-of-the-day-unsplash.vercel.app%2Fsitemap.xml'
# echo "Exit code: $?"
# if [[ "$?" -gt 0 ]]; then exit 1; else exit 0; fi
## shell: bash
# v2 google - DEPRECATED
#- name: Step 2/2 - Sitemap-Ping - google.com
# run: |
# STATUS=$(curl -isSL -o /dev/null -w "%{http_code}" --url 'https://www.google.com/ping?sitemap=https%3A%2F%2Fphoto-of-the-day-unsplash.vercel.app%2Fsitemap.xml')
# echo ""
# echo "Status code: $STATUS"
# echo "Exit code: $?"
# # exit 1 aborts job with an error; exit 0 means "all good, move on"
# if [[ STATUS -ne 200 || "$?" -gt 0 ]]; then exit 1; else exit 0; fi
# v1 bing - stopped working
#- name: Step 3/3 - Sitemap-Ping - bing.com
# run: |
# curl -isSL -o /dev/null -w "%{http_code}\n" \
# --url 'https://www.bing.com/webmaster/ping.aspx?siteMap=https%3A%2F%2Fphoto-of-the-day-unsplash.vercel.app%2Fsitemap.xml'
# echo "Exit code: $?"
# if [[ "$?" -gt 0 ]]; then exit 1; else exit 0; fi
# shell: bash
# v2 bing - stopped working
#- name: Step 2/2 - Sitemap-Ping - bing.com
# run: |
# STATUS=$(curl -isSL -o /dev/null -w "%{http_code}" --url 'https://www.bing.com/webmaster/ping.aspx?siteMap=https%3A%2F%2Fphoto-of-the-day-unsplash.vercel.app%2Fsitemap.xml')
# echo ""
# echo "Status code: $STATUS"
# echo "Exit code: $?"
# # exit 1 aborts job with an error; exit 0 means "all good, move on"
# if [[ STATUS -ne 200 || "$?" -gt 0 ]]; then exit 1; else exit 0; fi