File tree 3 files changed +22
-6
lines changed
3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ Update coder templates automatically
25
25
| ` activate` | Activate the new template version. | ` true` |
26
26
| ` create` | Creates a new template if it does not exist | ` true` |
27
27
| ` message` | Update message (similar to commit messages) | - |
28
+ | ` dry_run` | Dry run mode. | ` false` |
28
29
29
30
# # Examples
30
31
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ inputs:
34
34
description : " Creates a new template if it does not exist"
35
35
required : false
36
36
default : " true"
37
+ dry_run :
38
+ description : " Dry run"
39
+ required : false
40
+ default : " false"
37
41
38
42
runs :
39
43
using : " composite"
43
47
env :
44
48
CODER_URL : ${{ inputs.url }}
45
49
46
- - run : push_template.sh
50
+ - run : ${{ github.action_path }}/ push_template.sh
47
51
shell : bash
48
52
env :
49
53
CODER_SESSION_TOKEN : ${{ inputs.coder_session_token }}
54
58
CODER_TEMPLATE_ACTIVATE : ${{ inputs.activate }}
55
59
CODER_TEMPLATE_MESSAGE : ${{ inputs.message }}
56
60
CODER_TEMPLATE_CREATE : ${{ inputs.create }}
57
-
61
+ CODER_TEMPLATE_DRY_RUN : ${{ inputs.dry_run }}
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ echo "CODER_TEMPLATE_ID: ${CODER_TEMPLATE_ID}"
12
12
echo " CODER_TEMPLATE_DIR: ${CODER_TEMPLATE_DIR} "
13
13
14
14
# Construct push command
15
- push_command=" coder templates push ${CODER_TEMPLATE_NAME} --directory ./${CODER_TEMPLATE_DIR} " --message ${CODER_TEMPLATE_MESSAGE}
15
+ push_command=" coder templates push ${CODER_TEMPLATE_ID} --directory ./${CODER_TEMPLATE_DIR} "
16
+
17
+ # Add message to the push command if specified
18
+ if [ -n " ${CODER_TEMPLATE_MESSAGE} " ]; then
19
+ push_command+=" --message \" ${CODER_TEMPLATE_MESSAGE} \" "
20
+ fi
16
21
17
22
# Append --create flag to the push command if CODER_TEMPLATE_CREATE is true
18
23
if [ " ${CODER_TEMPLATE_CREATE} " = " true" ]; then
32
37
# Add confirmation flag to the push command
33
38
push_command+=" --yes"
34
39
35
- # Execute the push command
36
- ${push_command}
37
-
40
+ # Execute the push command if no dry run
41
+ if [ " ${CODER_TEMPLATE_DRY_RUN} " = " false" ]; then
42
+ echo " Pushing ${CODER_TEMPLATE_DIR} to ${CODER_URL} ..."
43
+ eval ${push_command}
44
+ echo " A new version of ${CODER_TEMPLATE_DIR} is pushed to ${CODER_URL} successfully."
45
+ exit 0
46
+ fi
47
+ echo " Dry run is enabled. The following command will be executed:"
48
+ echo ${push_command}
38
49
echo " A new version of ${CODER_TEMPLATE_DIR} is pushed to ${CODER_URL} successfully."
You can’t perform that action at this time.
0 commit comments