GitHub CLI 1.0.0 has been released! ๐
But I donโt think it is useful for me. So letโs find out what I could use it for. The very first idea that comes to my mind is to use it for automating the workflow of blog publishing.
Here is some background information about my workflow.
Github
Create PR: master โ (A) โ deployment
Merge โ(B)
Netlify โ
Deploy Hook: Watch
โ(C)
Trigger
Currently, in order to publish the new post to my blog, I need to conduct the following steps manually.
(A) Create PR from work branch to publish branch
(B) Merge PR to bring updated post files to publish branch
(C) Trigger hook to deploy based on publish branch
Then, here is the implementation of automating the workflow of blog publishing in a makefile. Each step is implemented independently and the whole workflow is conducted by the sequence (A๐กB๐กC).
NAME := portal-deployer
work_branch := master
publish_branch := deployment
pr_label := Publish
pr_title = Publish $(shell date +%Y/%m/%d)
pr_url = $(shell gh pr view master | grep url | awk '{print $$2}')
deploy_hook = $(NETLIFY_DEPLOY_HOOK)
## (A) Create pull request for publishing in Github
.PHONY: create
create:
gh pr create --title "$(pr_title)" --body "Generated by $(NAME)" \
--base $(publish_branch) --head $(work_branch) --label $(pr_label)
## (B) Merge pull request for publishing in Github
.PHONY: merge
merge:
gh pr merge $(pr_url) --delete-branch=false --merge
## (C) Trigger deploy in Netlify
.PHONY: deploy
deploy:
curl -X POST -d '{}' $(deploy_hook)
P.S. This post is published by using this workflow. I hope some imformation might be helpful to you.