Add video for NDC 2024 #182
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ | |
-w /srv/jekyll \ | |
ruby:3.2.5 /bin/bash -c "gem install bundler && bundle install && 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 X account](https://x.com/DamnDotEngineer) for new post notifications, and reach me through my [personal X](https://x.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 }} |