Sync articles #33565
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: Sync articles | |
| # Controls when the action will run. Workflow runs when manually triggered using the UI or API. | |
| on: | |
| schedule: | |
| - cron: '*/10 8-21 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: 'Synchronize all posts.' | |
| required: true | |
| default: false | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| # Concurrency allows you to run multiple jobs in parallel, but only one job at a time | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # 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@v6 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.4.2 | |
| bundler-cache: true | |
| - name: Run sync script | |
| env: | |
| DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }} | |
| run: | | |
| if [ "${{ github.event.inputs.force }}" = "true" ] | |
| then | |
| bundle exec bin/sync_with_devto -f | |
| else | |
| bundle exec 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) |