-
Notifications
You must be signed in to change notification settings - Fork 71
74 lines (65 loc) · 2.16 KB
/
build-ami.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
name: Build AWS Neuron AMI
on:
push:
branches:
- main
paths:
- 'aws-ami-creation/**'
pull_request:
branches:
- main
paths:
- 'aws-ami-creation/**'
workflow_dispatch:
inputs:
tag:
description: 'Tag to use for the AMI build'
default: 'main'
schedule:
# Schedule the workflow to run every second day at midnight UTC
- cron: '0 0 */2 * *'
jobs:
build-ami:
defaults:
run:
working-directory: infrastructure/ami
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag}}
- name: Setup Packer
- uses: hashicorp/setup-packer@main
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Packer format
id: format
run: packer fmt hcl2-files
continue-on-error: true
- name: Packer Init
id: init
run: packer init hcl2-files
continue-on-error: true
- name: Packer Validate
id: validate
run: packer validate hcl2-files
continue-on-error: true
- name: Packer Build
id: build
run: |
packer build -var "optimum_neuron_tag=${{ steps.determine-tag.outputs.TAG }}" hcl2-files
- name: Slack Notification on Failure
if: ${{ failure() && github.event_name == 'schedule' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_USERNAME: 'GitHub Action Optimum Neuron AMI'
SLACK_ICON_EMOJI: ':bell:'
SLACK_COLOR: 'danger'
SLACK_TITLE: 'Build AWS Neuron AMI Failed'