Skip to content

[automated change] Closes #37 #56

[automated change] Closes #37

[automated change] Closes #37 #56

Workflow file for this run

name: Publish
on:
push:
paths-ignore:
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
jobs:
build:
runs-on: ubuntu-latest
outputs:
# This var is set by peaceiris/actions-gh-pages only when there is new content
# or commits on the gh-pages branch
dst_sha: ${{ steps.pages.outputs.dst_sha }}
steps:
- name: Checkout source files
uses: actions/checkout@v2
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.69.2'
- name: Build
run: hugo --minify
- name: Deploy
id: pages
uses: peaceiris/actions-gh-pages@7e55c73ee896b01b8b8668370794b96f1bc9c759 #514
if: github.ref == 'refs/heads/main' # avoid publishing other branches
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: hugo-site
# This job is only executed if there was a commit on the precedent build step
notify:
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.dst_sha
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/post-to-twitter/requirements.txt
pip install -r scripts/post-to-telegram/requirements.txt
# Check out the generated JSON file and put it on the current workspace
# and set the variable json-post with the filename to be used for other
# scripts
- name: Get new JSON content file
id: new-content
run: |
echo ${{ needs.build.outputs.dst_sha }}
json_post=$(./bin/extract-json-file.sh ${{ needs.build.outputs.dst_sha }})
echo ::set-output name=json-post::$json_post
- name: Post on Telegram
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_DRY_RUN: ${{ secrets.TELEGRAM_DRY_RUN }}
run: |
echo "Posting content to Telegram from ${{ steps.new-content.outputs.json-post }}"
./scripts/post-to-telegram/main.py ${{ steps.new-content.outputs.json-post }}
- name: Post on Twitter
env:
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_DRY_RUN: ${{ secrets.TWITTER_DRY_RUN }}
run: |
echo "Posting content Twitter from ${{ steps.new-content.outputs.json-post }}"
./scripts/post-to-twitter/main.py ${{ steps.new-content.outputs.json-post }}