-
Notifications
You must be signed in to change notification settings - Fork 8
65 lines (60 loc) · 2.49 KB
/
alert.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
name: Publish Alerts
on:
# run everyday at 12:20 utf ( 8:20 am est) to alert on new posts
schedule:
- cron: '40 12 * * *'
workflow_dispatch:
jobs:
build-website:
name: Build Alert List
runs-on: ubuntu-latest
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- name: Checkout code
uses: actions/checkout@v2
## Write into published.txt what's been published
## Write into steps.published_check.outputs the outputs
- name: Has new published documents
id: published_check
run: |-
if [ "$CI_ACTION_REF_NAME" == "main" ]; then
pattern=$(date '+%Y-%m-%d')
if test -n "$(find ./blog/_posts -maxdepth 1 -name "*$pattern*" -print)"
then
echo "Setting Publish Flag"
echo "PUBLISHED=1" >> $GITHUB_ENV
echo "Writing blog paths to posts.txt"
find ./blog/_posts -maxdepth 1 -name "*$pattern*" -print > posts.txt
echo "Writing list of post urls to PUBLISHED_LIST for future steps"
echo 'PUBLISHED_LIST<<EOF' >> $GITHUB_ENV
awk '{ print "https://earthly.dev/blog/"substr( $0, 26, length($0)-28 ) }' < posts.txt | tr '\n' "," | sed 's/,/\\n/g' >> $GITHUB_ENV
echo '\n' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
fi
fi
## Check output value for whether file exists
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "posts.txt"
# Output published list
- name: Slack Notification
id: slack1
if: steps.check_files.outputs.files_exists == 'true'
run: |-
echo "Community Blog Alert"
curl -X POST -H 'Content-type: application/json' --data '{"text":"${{ env.PUBLISHED_LIST }}"}' $SLACK_WEBHOOK_URL
env:
## Zapier web hook (which controls formatting)
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# Output blog post for
- name: Slack Community Notification
id: slack2
if: steps.check_files.outputs.files_exists == 'true'
run: |-
echo "Community Blog Alert"
curl -X POST -H 'Content-type: application/json' --data '{"text":"${{ env.PUBLISHED_LIST }}"}' $SLACK_WEBHOOK_URL
env:
## Zapier web hook (which controls formatting)
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_COMMUNITY_BLOG_WEBHOOK_URL }}