-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (100 loc) · 4.72 KB
/
jekyll-publish.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Publish site
on:
workflow_dispatch:
push:
branches: [master]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Replace development URL
run: sed -i 's!http://127.0.0.1:4000!https://damn.engineer!g' ${{ github.workspace }}/_config.yml
- name: Build Jekyll site
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build --future"
- name: Download latest.json for comparison
run: wget https://damn.engineer/latest.json -O ${{ github.workspace }}/current-latest.json
- name: Check if a new post has been created
id: new-post-check
uses: LouisBrunner/[email protected]
with:
old: ${{ github.workspace }}/current-latest.json
new: ${{ github.workspace }}/_site/latest.json
mode: addition
tolerance: mixed
- name: Deploy to Azure Static Web App
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: upload
app_location: ${{ github.workspace }}/_site
skip_app_build: true
output_location: ""
- name: Get new post info
if: contains(steps.new-post-check.outputs.output, 'title')
run: |
latest=${{ github.workspace }}/_site/latest.json
echo "NEW_POST_TITLE=$(jq -r '.title' $latest)" >> $GITHUB_ENV
echo "NEW_POST_URL=$(jq -r '.url' $latest)" >> $GITHUB_ENV
echo "NEW_POST_FILENAME=$(jq -r '.filename' $latest)" >> $GITHUB_ENV
echo "PUBLISH_TO_LINKEDIN=$(jq -r '.linkedin' $latest)" >> $GITHUB_ENV
echo "PUBLISH_TO_MEDIUM=$(jq -r '.medium' $latest)" >> $GITHUB_ENV
- name: Tweet new article
uses: Eomm/why-don-t-you-tweet@v1
if: contains(steps.new-post-check.outputs.output, 'title')
with:
tweet-message: "New post:\n${{ env.NEW_POST_TITLE }}\n${{ env.NEW_POST_URL }}\n#DevOps #Cloud #InfrastructureAsCode #CICD"
env:
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
- name: Publish on LinkedIn through IFTTT
uses: actionsflow/ifttt-webhook-action@v1
if: |
contains(steps.new-post-check.outputs.output, 'title')
&& env.PUBLISH_TO_LINKEDIN == 'true'
with:
event: new_damn_engineer_blog_post
key: ${{ secrets.IFTTT_WEBHOOK_KEY }}
value1: ${{ env.NEW_POST_TITLE }}
value2: ${{ env.NEW_POST_URL }}
- name: Extract Markdown from latest post
if: |
contains(steps.new-post-check.outputs.output, 'title')
&& env.PUBLISH_TO_MEDIUM == 'true'
run: |
echo "# ${{ env.NEW_POST_TITLE }}" > latest.md
sed '/---/,/---/d;s!{{ site.url }}{{ site.baseurl }}!https://damn.engineer!g' $NEW_POST_FILENAME >> latest.md
echo -e "\n*This story was originally published on my personal blog, [damn.engineer](https://damn.engineer).*\n*You can follow the [blog's Twitter account](https://twitter.com/DamnDotEngineer) for new post notifications, and reach me through my [personal Twitter](https://twitter.com/theEugeneRomero).*" >> latest.md
- name: Create Medium draft
uses: philips-software/[email protected]
id: medium-draft
if: |
contains(steps.new-post-check.outputs.output, 'title')
&& env.PUBLISH_TO_MEDIUM == 'true'
with:
integration_token: "${{ secrets.MEDIUM_ACCESS_TOKEN }}"
file: latest.md
content_format: "markdown"
notify_followers: "false"
publication_id: ${{ secrets.MEDIUM_CAP_NORWAY_ID }}
tags: "Technology,DevOps,Cloud,Cloud Computing,Software Development"
title: ${{ env.NEW_POST_TITLE }}
canonical_url: ${{ env.NEW_POST_URL }}
license: "all-rights-reserved"
publish_status: "draft"
- name: Notify about new Medium draft
uses: actionsflow/ifttt-webhook-action@v1
if: |
contains(steps.new-post-check.outputs.output, 'title')
&& env.PUBLISH_TO_MEDIUM == 'true'
with:
event: new_medium_draft
key: ${{ secrets.IFTTT_WEBHOOK_KEY }}
value1: ${{ env.NEW_POST_TITLE }}
value2: ${{ steps.medium-draft.outputs.url }}