File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 38
38
type : string
39
39
description : " Overrides default of latest hugo theme. Useful for testing pre-release versions. Must start with 'v' before version."
40
40
default : " "
41
+ auto_deploy_branch :
42
+ type : string
43
+ description : " Branch specified here will autodeploy to production. An on.push for this branch must be specified in caller."
44
+ auto_deploy_env :
45
+ type : string
46
+ description : " Env to which auto_deploy_branch will be deployed to. Preview is not supported."
41
47
42
48
env :
43
49
GO_VERISON : " 1.21" # Go version used for `hugo mod get`
@@ -83,10 +89,21 @@ jobs:
83
89
EVENT_ACTION : ${{github.event.action}}
84
90
DEPLOYMENT_ENV : ${{inputs.environment}}
85
91
THEME_VERSION : ${{inputs.force_hugo_theme_version}}
92
+ AUTO_DEPLOY_BRANCH : ${{inputs.auto_deploy_branch}}
93
+ AUTO_DEPLOY_ENV : ${{inputs.auto_deploy_env}}
86
94
87
95
concurrency :
88
96
group : ${{ github.workflow }}-${{ github.ref }}
89
97
steps :
98
+ - name : Check and setup auto-deploy
99
+ # Auto deploy should only trigger when the auto_deploy_branch match the current ref.
100
+ # We also check if `environment` has already been set, otherwise this flow could cause
101
+ # manual triggers to deploy to `auto_deploy_env` instead of the one specified in the trigger.
102
+ if : (inputs.auto_deploy_branch == github.ref_name) && inputs.environment == ''
103
+ run : |
104
+ echo "Auto deploy branch ($AUTO_DEPLOY_BRANCH) matches current branch. Attempting autodeploy to $AUTO_DEPLOY_ENV."
105
+ echo "DEPLOYMENT_ENV=${AUTO_DEPLOY_ENV}" >> $GITHUB_ENV
106
+
90
107
- name : Validate environment inputs
91
108
run : |
92
109
if [[ -z "${DEPLOYMENT_ENV}" ]]; then
Original file line number Diff line number Diff line change 82
82
branches :
83
83
- " *"
84
84
85
+ # Used for auto deploy builds. This branch _must_ match auto_deploy_branch
86
+ push :
87
+ branches :
88
+ - " main"
89
+
85
90
jobs :
86
91
# Configure the build
87
92
call-docs-build-push :
93
98
docs_build_path : " ./"
94
99
doc_type : " hugo"
95
100
environment : ${{inputs.environment}}
101
+ # This means, any time there's a push to main, a deployment will automatically be made to dev.
102
+ auto_deploy_branch : " main"
103
+ auto_deploy_env : " dev"
96
104
secrets :
97
105
AZURE_CREDENTIALS : ${{secrets.AZURE_CREDENTIALS}}
98
106
AZURE_KEY_VAULT : ${{secrets.AZURE_KEY_VAULT}}
You can’t perform that action at this time.
0 commit comments