Skip to content

Commit a744181

Browse files
committed
Get branch name for passing to packer
1 parent 6673c29 commit a744181

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.github/workflows/build-ami.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,21 @@ jobs:
5555
run: packer init hcl2-files
5656
continue-on-error: true
5757

58+
- name: Determine Branch name
59+
id: get-branch-name
60+
run:
61+
5862
- name: Packer Validate
5963
id: validate
60-
# If the workflow is triggered manually or scheduled, uses the tag, otherwise uses the current branch for building the AMI
61-
run: packer validate -var "optimum_version=${{ github.event.inputs.tag || github.ref }}" -var "region=${{ env.AWS_REGION }}" hcl2-files
64+
# If the workflow is triggered manually or scheduled, uses the tag, otherwise uses the name of branch that triggered worklfow for building the AMI
65+
run: packer validate -var "optimum_version=${{ github.event.inputs.tag || github.head_ref || github.ref_name }}" -var "region=${{ env.AWS_REGION }}" hcl2-files
6266
continue-on-error: true
6367

6468
- name: Packer Build
6569
id: build
66-
# If the workflow is triggered manually or scheduled, uses the tag, otherwise uses the current branch for building the AMI
70+
# If the workflow is triggered manually or scheduled, uses the tag, otherwise uses the name of branch that triggered worklfow for building the AMI
6771
run: |
68-
packer build -var "optimum_version=${{ github.event.inputs.tag || github.ref }}" -var "region=${{ env.AWS_REGION }}" hcl2-files
72+
packer build -var "optimum_version=${{ github.event.inputs.tag || github.head_ref || github.ref_name }}" -var "region=${{ env.AWS_REGION }}" hcl2-files
6973
7074
- name: Slack Notification on Failure
7175
id: slack

0 commit comments

Comments
 (0)