|
4 | 4 | inputs: |
5 | 5 | post_title: |
6 | 6 | description: 'Used for filename and post.sh name. The space will be replaced by `-` inv the file name.' |
7 | | - default: 'Event#' |
| 7 | + default: '' |
8 | 8 | required: true |
9 | 9 | post_body: |
10 | 10 | description: 'Use GitHub MD format' |
|
25 | 25 |
|
26 | 26 | env: |
27 | 27 | FILENAME_PREFIX: ./_posts/$(date +'%Y-%m-%d')-$( echo '${{ github.event.inputs.post_title }}' | sed -r 's/[# ]+/-/g' ).md |
28 | | - FILENAME: ./_posts/$(date +'%Y-%m-%d')-$( echo '${{ github.event.inputs.post_title }}' | sed -r 's/[# ]+/-/g' ).md |
29 | 28 | MESSAGE: ${{ github.event.inputs.post_body }} |
30 | 29 | POST: | |
31 | 30 | --- |
|
46 | 45 | - name: Calculate event number |
47 | 46 | run: | |
48 | 47 | lastEvent=$(ls -LR1 | sed -E 's/[0-9]{4}-[0-9]{2}-[0-9]{2}-//;s/Event-//;s/-.*//;s/.md//' | sort -n | tail -1) |
49 | | - echo "next_event=$((lastEvent+1))" >> $GITHUB_ENV |
50 | | - echo "FILENAME=$((lastEvent+1))" >> $GITHUB_ENV |
| 48 | + nextEvent=$((lastEvent+1)) |
| 49 | + filename=$( echo "Event-$nextEvent-${{ github.event.inputs.post_title }}" | sed -r 's/[ ]+/-/g' ).md |
| 50 | + echo "next_event=$nextEvent" >> $GITHUB_ENV |
| 51 | + echo "FILENAME=${{ env.FILENAME_PREFIX }}${filename}" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + - name: Create post |
| 54 | + run: | |
| 55 | + echo 'POST<<EOF' >> $GITHUB_ENV |
| 56 | + echo '---' >> $GITHUB_ENV |
| 57 | + echo 'layout: post' >> $GITHUB_ENV |
| 58 | + echo 'title: \"${{ github.event.inputs.post_title }}\"' >> $GITHUB_ENV |
| 59 | + echo 'image: /images/default.jpg' >> $GITHUB_ENV |
| 60 | + echo 'tags: [${{ github.event.inputs.tags }}]' >> $GITHUB_ENV |
| 61 | + echo 'date: $(date +'%Y-%m-%d %H:%M:%S %z')' >> $GITHUB_ENV |
| 62 | + echo 'video: ' >> $GITHUB_ENV |
| 63 | + echo '---' >> $GITHUB_ENV |
| 64 | + echo '' >> $GITHUB_ENV |
| 65 | + echo '${{ github.event.inputs.post_body }}' >> $GITHUB_ENV |
| 66 | + echo 'EOF' >> $GITHUB_ENV |
51 | 67 | |
52 | 68 | - name: Create post file |
53 | 69 | run: | |
|
58 | 74 | git config --global user.email "releases@lvivjavaclub.github.io" |
59 | 75 | git config --global user.name "GitHub actions" |
60 | 76 | git add ${{ env.FILENAME }} |
61 | | - git commit -m 'Create ${{ github.event.inputs.post_title }}' |
| 77 | + git commit -m 'Create Event#${{ env.next_event }} ${{ github.event.inputs.post_title }}' |
62 | 78 | git push |
63 | 79 |
|
0 commit comments