-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
80 lines (72 loc) · 2.16 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Build marketplace images
description: |
Building disk images for
1. DigitalOcean
2. AWS (AMI)
.. and more
inputs:
tag:
description: |
Rocket.Chat version tag
required: true
digitalocean-token:
required: false
description: DigitalOcean token
aws-key-id:
required: false
description: AWS key id
aws-secret-key:
required: false
description: AWS secret key
source:
description: Packer source
required: true
runs:
using: composite
steps:
- name: Check if we should run this action or not
shell: bash
run: |
passed_tag=${{ inputs.tag }}
echo "passed_tag: $passed_tag"
current_released=$(
git -c 'versionsort.suffix=-' ls-remote -t --exit-code --refs --sort=-v:refname "https://github.com/RocketChat/rocketchat-packer" '*' |
awk -F/ '{ print $NF; exit }'
)
echo "current_released: $current_released"
is_gt() {
local v1=(${1//./ })
local v2=(${2//./ })
(( ${v1[0]} > ${v2[0]} )) && return 0
(( ${v1[1]} > ${v2[1]} )) && return 0
(( ${v1[2]} > ${v2[2]} )) && return 0
return 1
}
is_gt $passed_tag $current_released
- name: Checkout repository
uses: actions/checkout@v2
with:
repository: RocketChat/rocketchat-packer
- name: Validate template
uses: hashicorp/packer-github-actions@master
with:
command: validate
arguments: -syntax-only
target: config.pkr.hcl
- name: Initialize plugins
uses: hashicorp/packer-github-actions@master
with:
command: init
target: config.pkr.hcl
- name: Build images
uses: hashicorp/packer-github-actions@master
with:
command: build
arguments: ${{ format('-color=false -on-error=cleanup -only={0}', inputs.source) }}
target: config.pkr.hcl
env:
PACKER_LOG: '1'
PKR_VAR_rocketchat_version: ${{ inputs.tag }}
PKR_VAR_do_token: ${{ inputs.digitalocean-token }}
PKR_VAR_aws_key_id: ${{ inputs.aws-key-id }}
PKR_VAR_aws_secret_key: ${{ inputs.aws-secret-key }}