Site build #256
This file contains hidden or 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: Site build | |
on: | |
workflow_dispatch: | |
inputs: | |
speaker: | |
description: 'Specify the speaker of the event' | |
default: '' | |
required: true | |
post_title: | |
description: 'Used for filename and post.sh name. The space will be replaced by `-` inv the file name.' | |
default: '' | |
required: true | |
post_body: | |
description: 'Use GitHub MD format' | |
default: 'This week on Java Club we will review the' | |
required: true | |
room: | |
description: 'Choose place: Online|in Jamaica (room 223)|in Spain (room 426)' | |
default: 'Online' | |
required: true | |
tags: | |
description: 'Capitalized Tags separated by commas' | |
default: '' | |
required: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
env: | |
FILENAME_PREFIX: ./_posts/$(date +'%Y-%m-%d')- | |
MESSAGE: ${{ github.event.inputs.post_body }} | |
JOIN: Join us next Thursday, at 10:00 ${{ github.event.inputs.room }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Calculate event number | |
run: | | |
lastEvent=$(ls -LR1 | sed -E 's/[0-9]{4}-[0-9]{2}-[0-9]{2}-//;s/Event-//;s/-.*//;s/.md//' | sort -n | tail -1) | |
nextEvent=$((lastEvent+1)) | |
filename=$( echo "Event-$nextEvent-${{ github.event.inputs.post_title }}" | sed -r 's/[ ]+/-/g' ).md | |
echo "next_event=$nextEvent" >> $GITHUB_ENV | |
echo "FILENAME=${{ env.FILENAME_PREFIX }}${filename}" >> $GITHUB_ENV | |
- name: Create post | |
run: | | |
date=$(date +'%Y-%m-%d %H:%M:%S %z') | |
echo "POST<<EOF" >> $GITHUB_ENV | |
echo "---" >> $GITHUB_ENV | |
echo "layout: post" >> $GITHUB_ENV | |
echo "title: \"Event#${{ env.next_event }} ${{ github.event.inputs.post_title }} by ${{ github.event.inputs.speaker }}\"" >> $GITHUB_ENV | |
echo "image: /images/feed.jpg" >> $GITHUB_ENV | |
echo "tags: [${{ github.event.inputs.tags }}]" >> $GITHUB_ENV | |
echo "date: $date" >> $GITHUB_ENV | |
echo "video: " >> $GITHUB_ENV | |
echo "---" >> $GITHUB_ENV | |
echo '' >> $GITHUB_ENV | |
echo "${{ github.event.inputs.post_body }}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create post file | |
run: | | |
echo -e "${{ env.POST }}\n${{ env.JOIN }}" > "${{ env.FILENAME }}" | |
- name: Push new post | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub actions" | |
git add ${{ env.FILENAME }} | |
git commit -m 'Create Event#${{ env.next_event }} ${{ github.event.inputs.post_title }}' | |
git push | |