qian256.github.io icon indicating copy to clipboard operation
qian256.github.io copied to clipboard

Automated tag generation

Open MolotovCherry opened this issue 3 years ago • 0 comments

Hi,

I read your post on the tags. Thanks for the setup.

I just wanted to let you know of an automated way to do this that I made.

You can make a GitHub Action workflow, like mine here. It checks out the repo on every single push, runs a script to check all posts and add/delete tag files, then uses a github action to create a pull request, enable automerge, then merge it, all without you lifting a single finger on your end. 100% automated tag file creation.

My corresponding tag updater script the workflow runs is here.

In order to do this, you will need a special token you create by going to account settings -> Developer settings -> Personal access tokens -> create a new token with permissions repo, workflow. Copy the token code and paste it into the repository secrets section of your repo and use that same secret within the workflow.

Then go to your repo settings, under General tab, enable Allow auto-merge and Automatically delete head branches. Next, go to your Branches tab and add a branch protection rule for your main branch (this is required in order to enable auto merge). There are different kinds of protection rules you can enable for this. For mine, I enabled Require a pull request before merging and Require approvals (one person), then in my workflow script I added an action which auto approves the PR (you need to use your REPO_SCOPED_TOKEN for that, as the GITHUB_TOKEN cannot approve your own PR)

More info on the specific rules on how to use the auto PR github action and auto-merge github action here and here

Have fun with your own personal automated tag generation! You can go ahead and forget to run the script now since it won't matter :wink:

P.P.P.P.S. My site layout completely changed and I'm no longer using the exact same script or the default github pages env. I linked to the old commit; see the latest repo to see the newest stuff. Now no pull request is required, there's no need to upload custom tag files or anything, and they will all magically appear and be deployed automatically. This is because I'm using this workflow now which allows for usage of any plugin you desire

MolotovCherry avatar Mar 29 '22 03:03 MolotovCherry