Skip to content

Sync articles

Sync articles #4605

name: Sync articles
# Controls when the action will run. Workflow runs when manually triggered using the UI or API.
on:
schedule:
- cron: '*/10 4-21 * * *'
workflow_dispatch:
inputs:
force:
description: 'Synchronize all posts.'
required: true
default: false
permissions:
contents: write
pages: write
id-token: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
run_sync:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
- name: Install dependencies
run: |
gem install bundler
bundle install
- name: Run sync script
env:
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }}
run: |
if [ "${{ github.event.inputs.force }}" = "true" ]
then
bin/sync_with_devto -f
else
bin/sync_with_devto
fi
- name: Commit and push if it changed
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git add -A
git diff --quiet && git diff --staged --quiet || (git commit -m 'Update blog content'; git push)