Skip to content

Instantly share code, notes, and snippets.

@kmrn
Last active December 29, 2022 11:33
Show Gist options
  • Save kmrn/2e36236279f525b24a620b727861ad58 to your computer and use it in GitHub Desktop.
Save kmrn/2e36236279f525b24a620b727861ad58 to your computer and use it in GitHub Desktop.
GitHub Action to add and commit a new Jekyll blog post
name: Post release to Jekyll Blog
on:
release:
types: [published]
# The GitHub Actions workflow Spincord uses to create and publish a new blog post for every published git tag release.
# This workflow is set up to publish a new blog post to the Spincord gh-pages/jekyll
# site every time a new release is published. The blog post uses the corresponding tag
# name in the title along with the release's body and the current date.
jobs:
post:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: 'gh-pages' # change to relevant github pages branch
- name: Create blog post
# the shell script for curling the release info that's then parsed and read into vars with jq
# api url can be changed to whatever
run: |
read release_name release_date release_url release_body < <(echo $(curl -s -H "Accept: application/vnd.github.v3+json" 'https://api.github.com/repos/kmrn/spincord/releases/latest' | jq -r '.tag_name, .published_at, .url, .body'))
cat << EOF > ./_posts/$(date +%F)-release-$release_name.markdown
---
layout: post
title: Release $release_name
date: $release_date
author: actions-user
categories: release
---
$release_body
[View this release on GitHub]($release_url)
EOF
- name: Add and commit
uses: EndBug/[email protected]
with:
author_name: Github Actions
author_email: [email protected]
message: 'post release info to blog'
ref: 'gh-pages'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment