-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (74 loc) · 3.39 KB
/
lint-cfn.yml
File metadata and controls
88 lines (74 loc) · 3.39 KB
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
80
81
82
83
84
85
86
87
88
on:
workflow_call:
inputs:
cfn-template-file-1:
description: "The path to a CloudFormation template .yml or .yaml file to be linted."
required: true
type: string
cfn-template-file-2:
description: "(Optional) The path to another CloudFormation template .yml or .yaml file to be linted."
required: false
type: string
default: ""
cfn-lint-additional-command:
description: "(Optional) Used to pass a space delimited set of rules to ignore. cfn-lint will only check rules whose ID do not match or prefix these values. For ex: `-i W3002`"
required: false
type: string
default: ""
secrets:
env-github-token:
description: "A valid GitHub token to be used by the action."
required: true
jobs:
verify-cloudformation-formatting:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Echo Version
run: |
echo 'lint-cfn v1.4.0'
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Setup CloudFormation Formatter
run: |
gh release download --repo aws-cloudformation/rain --pattern "*_linux-amd64.zip" --output "rain.zip"
unzip -j "rain.zip" "*/rain"
env:
GH_TOKEN: ${{ secrets.env-github-token }}
- name: Verify with CloudFormation Formatter
continue-on-error: true
run: |
./rain fmt --verify ${{ inputs.cfn-template-file-1 }} ${{ inputs.cfn-template-file-2 }}
- name: Advice for Addressing Action Failure - CloudFormation Formatting
if: failure()
run: |
echo 'Your build failed due to your CloudFormation template file(s) requiring edits to pass our required formatting rules.'
echo 'Please review the previous "Verify with CloudFormation Formatter" step to see which file(s) need to be formatted.'
echo 'You need to format the CloudFormation file(s) using the autoformatter before commiting your change.'
echo 'Consult the ReadMe for guidance https://github.com/VirdocsSoftware/github-actions/tree/main#cfn-formatting-rain'
verify-cloudformation-linting:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Echo Version
run: |
echo 'lint-cfn v1.4.0'
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Setup CloudFormation Linter
uses: scottbrenner/cfn-lint-action@v2
- name: Verify with CloudFormation Linter
continue-on-error: true
run: |
cfn-lint --version
echo 'Running CFN Linter on ${{ inputs.cfn-template-file-1 }} ${{ inputs.cfn-template-file-2 }}'
cfn-lint -t ${{ inputs.cfn-template-file-1 }} ${{ inputs.cfn-template-file-2 }} ${{ inputs.cfn-lint-additional-command }}
- name: Advice for Addressing Action Failure - CloudFormation Linting
if: failure()
run: |
echo 'Your build failed due to your CloudFormation template file(s) requiring edits to pass our required linting rules.'
echo 'Please review the previous "Verify with CloudFormation Linter" step for more explicit failure reasoning.'
echo 'You need to correct the linting warnings and errors before commiting your change.'
echo 'Consult the ReadMe for guidance https://github.com/VirdocsSoftware/github-actions/tree/main#cfn-linting-cfn-lint'