|
| 1 | +# Packer Build Action |
| 2 | + |
| 3 | +Runs `packer build *.json` on release to validate and build image based on the template file in a directory |
| 4 | +This depends on the packer validate action, if the validation fails, it will print out error as pull request comment. |
| 5 | +Check out the inspect, validate actions and [packer build command][packer-build-doc] for further reference. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +To check this in action, please check [Packer actions demo project][packer-actions-demo] with a collection |
| 10 | +of sample packer template files. |
| 11 | + |
| 12 | +Variables |
| 13 | + |
| 14 | +- `PACKER_ACTION_WORKING_DIR` : Working directory |
| 15 | +- `TEMPLATE_FILE_NAME` : Packer template file |
| 16 | +- `ACTION_COMMENT` : Enable/Disable PR comment from validate result |
| 17 | + |
| 18 | +``` |
| 19 | +workflow "packer build template-y" { |
| 20 | + resolves = "packer-build-template-y" |
| 21 | + on = "release" |
| 22 | +} |
| 23 | +
|
| 24 | +action "packer-build-template-y" { |
| 25 | + uses = "dawitnida/packer-github-actions/build@master" |
| 26 | + needs = "packer-inspect-template-y" |
| 27 | + secrets = [ |
| 28 | + "GITHUB_TOKEN", |
| 29 | + ] |
| 30 | + env = { |
| 31 | + TEMPLATE_FILE_NAME = "packer-template-y.json" |
| 32 | + } |
| 33 | +} |
| 34 | +
|
| 35 | +action "filter-open-synced-pr" { |
| 36 | + uses = "actions/bin/filter@master" |
| 37 | + args = "action 'opened|synchronize'" |
| 38 | +} |
| 39 | +
|
| 40 | +workflow "packer inspect & validate template-y" { |
| 41 | + resolves = "packer-inspect-template-y" |
| 42 | + on = "pull_request" |
| 43 | +} |
| 44 | +
|
| 45 | +action "packer-validate-template-y" { |
| 46 | + uses = "dawitnida/packer-github-actions/validate@master" |
| 47 | + needs = "filter-open-synced-pr" |
| 48 | + secrets = [ |
| 49 | + "GITHUB_TOKEN", |
| 50 | + ] |
| 51 | + env = { |
| 52 | + TEMPLATE_FILE_NAME = "packer-template-y.json" |
| 53 | + } |
| 54 | +} |
| 55 | +
|
| 56 | +action "packer-inspect-template-y" { |
| 57 | + uses = "dawitnida/packer-github-actions/inspect@master" |
| 58 | + needs = "packer-validate-template-y" |
| 59 | + secrets = [ |
| 60 | + "GITHUB_TOKEN", |
| 61 | + ] |
| 62 | + env = { |
| 63 | + TEMPLATE_FILE_NAME = "packer-template-y.json" |
| 64 | + } |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +[packer-build-doc]: <https://www.packer.io/docs/commands/build.html> |
| 69 | +[packer-actions-demo]: <https://github.com/dawitnida/packer-actions-demo> |
0 commit comments