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

Commit 0de82f1

Browse files
authored
DX-2998 Update Blog Post Workflow (#899)
* 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
1 parent cee1d08 commit 0de82f1

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

.github/workflows/blog-posts.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
name: Update Blog Posts
1+
# Ingest repository_dispatch events for syncing blog posts
2+
name: Blog Posts Listener
23

34
on:
4-
schedule:
5-
- cron: '0 13 * * 1'
6-
workflow_dispatch:
5+
repository_dispatch:
6+
types: [Blog]
77

88
jobs:
9-
get_blog_posts:
10-
name: Get Most Recent Posts from Bandwidth Blog
9+
sync-blog-posts:
1110
runs-on: ubuntu-latest
12-
# outputs:
13-
# release_needed: ${{ steps.release_needed.outputs.release_needed }}
1411
steps:
15-
- name: Get Blog Posts from Wordpress API
16-
id: get_posts
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Configure Git and Create Branch
16+
run: |
17+
git config user.email "[email protected]"
18+
git config user.name "DX-Bandwidth"
19+
git checkout -b sync-blog-posts
20+
21+
- name: Update Blog Posts File
22+
run: |
23+
cat > ./site/blogposts.config.json <<< $POSTS_JSON
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
26+
POSTS_JSON: ${{ toJson(github.event.client_payload.posts) }}
27+
28+
- name: Commit Changes and Create Pull Request
1729
run: |
18-
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]')
19-
20-
echo $BLOG_POSTS
30+
git add site/blogposts.config.json
31+
git commit -m 'update blog posts'
32+
git push origin sync-blog-posts
33+
gh pr create -B main -H sync-blog-posts --title 'Update Blog Posts' --body 'Auto-generated by Blog Posts Listener Workflow'
2134
env:
22-
WORDPRESS_TOKEN: ${{ secrets.WORDPRESS_TOKEN }}
35+
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)