Initially, my usage of GitHub Actions only involves simple actions such as build, test. Besides, I can use contexts to read the current branch name. GitHub Actions does support the if key, but there is no else if / else. name: My workflow # Define which action triggers the workflow on: # Name of the action push: # Filter, define which branch triggers the action # I want all branches to trigger this workflow branches: - dev # Direct push is allowed, this deploys to a staging server - beta # Protected branch, no direct push, only accepted merge is allowed - main # Protected branch, no direct push, only accepted merge is allowed How about if / else if / else statement to check for branches? □ Yes, there is a key on to serve this purpose. With that said, how can I create one workflow which uses different secrets based on a triggered branch? Key points □ Can I make all 3 branches trigger the same workflow? □ Maintaining 3 different workflows, one for each, is not recommended due to duplicated code. In my case, only configurations (secrets and environment variables) are different. More details were discussed in my previous article. They have the same workflow, which is to build, test, and deploy my application to GCP App Engine. I have 3 different branches: dev, beta, and main. GitHub Actions provides the ability to create automated workloads, CI/CD pipelines. If you are unfamiliar with GitHub Actions, I recommend you read my introduction to GitHub Actions components article first! Problem statement □ Correction to any of the errors is welcome! The article presents some key points and questions I faced when going through the project. This is more about describing my personal development and debugging experience, less of a step-by-step tutorial on the topic.
0 Comments
Leave a Reply. |