Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
DX-2998 Update Blog Post Workflow (#899)
Browse files Browse the repository at this point in the history
* DX-2998 Workflow for Automatic Blog Post Retrieval

* update jq to only return first 10 posts

* echo response

* bearer token

* update to use hosted action runner

* push test file in case my machine is broken

* push again just in case

* update blog posts and workflow file

* remove test shell file

* remove carriage returns

* update to be listener

* use json array

* use toJson

* undo blogpost changes

* fix spaces
  • Loading branch information
ckoegel authored Jun 5, 2023
1 parent cee1d08 commit 0de82f1
Showing 1 changed file with 27 additions and 14 deletions.
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 "[email protected]"
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 }}

0 comments on commit 0de82f1

Please sign in to comment.