Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions .github/workflows/blog-posts.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
name: Update Blog Posts
# Ingest repository_dispatch events for syncing blog posts
name: Blog Posts Listener

on:
schedule:
- cron: '0 13 * * 1'
workflow_dispatch:
repository_dispatch:
types: [Blog]

jobs:
get_blog_posts:
name: Get Most Recent Posts from Bandwidth Blog
sync-blog-posts:
runs-on: ubuntu-latest
# outputs:
# release_needed: ${{ steps.release_needed.outputs.release_needed }}
steps:
- name: Get Blog Posts from Wordpress API
id: get_posts
- name: Checkout
uses: actions/checkout@v3

- name: Configure Git and Create Branch
run: |
git config user.email "dx@bandwidth.com"
git config user.name "DX-Bandwidth"
git checkout -b sync-blog-posts

- name: Update Blog Posts File
run: |
cat > ./site/blogposts.config.json <<< $POSTS_JSON
env:
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
POSTS_JSON: ${{ toJson(github.event.client_payload.posts) }}

- name: Commit Changes and Create Pull Request
run: |
BLOG_POSTS=$(curl -Ls -H "Authorization: token $WORDPRESS_TOKEN" https://www.bandwidth.com/wp-json/wp/v2/posts?per_page=20 | jq '[del(.[] | select(.categories[] | contains(1680))) | .[] | {imageId: .featured_media, categories: .categories, postLink: .link, postTitle: .title.rendered}] | .[:10]')

echo $BLOG_POSTS
git add site/blogposts.config.json
git commit -m 'update blog posts'
git push origin sync-blog-posts
gh pr create -B main -H sync-blog-posts --title 'Update Blog Posts' --body 'Auto-generated by Blog Posts Listener Workflow'
env:
WORDPRESS_TOKEN: ${{ secrets.WORDPRESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}