Skip to content

Commit a2d8907

Browse files
author
rafaelfernandezd
committed
Second commit
1 parent d9b41c6 commit a2d8907

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM mcr.microsoft.com/powershell:latest
2+
3+
# Install Git
4+
RUN apt-get update && \
5+
apt-get install -y git
6+
7+
# Clone ARM-TTK Repo
8+
RUN git clone https://github.com/Azure/arm-ttk.git
9+
10+
# Copy the Entrypoint file from the current directory (the one the Dockerfile is located in)
11+
COPY entrypoint.ps1 /entrypoint.ps1
12+
13+
# Start using the Entrypoint file.
14+
ENTRYPOINT [ "pwsh", "/entrypoint.ps1" ]

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Azure Resource Manager Template Toolkit action
2+
3+
This action "[use Azure Resource Manager Template Toolkit (arm-ttk)](https://github.com/Azure/arm-ttk)" for analyzing and testing Azure Resource Manager Templates.
4+
5+
It's my first GitHub Action and it's based on https://github.com/whaakman/armttk-github-action-demo
6+
7+
## Inputs
8+
9+
None
10+
11+
## Outputs
12+
13+
### `TestFailures`
14+
15+
Test Failures
16+
17+
## Example usage
18+
19+
```yaml
20+
uses: rfernandezdo/arm-ttk@master
21+
```

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# action.yml
2+
name: 'Run ARM TTK'
3+
description: 'Run ARM TTK in your project'
4+
outputs:
5+
TestFailures: # id of output
6+
description: 'Test Failures'
7+
runs:
8+
using: 'docker'
9+
image: 'Dockerfile'

entrypoint.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Import the arm-ttk module we cloned in the dockerfile
2+
Import-Module '/arm-ttk/arm-ttk/arm-ttk.psd1'
3+
4+
# Path we cloned the repository into
5+
$TemplatePath = ${env:GITHUB_WORKSPACE}
6+
7+
$TestResults = Test-AzTemplate -TemplatePath $TemplatePath
8+
# We only want to return failures
9+
$TestFailures = $TestResults | Where-Object { -not $_.Passed }
10+
11+
# If files are returning invalid configurations
12+
# Using exit code "1" to let Github actions node the test failed
13+
if ($TestFailures) {
14+
Write-Host "One or more templates did not pass the selected tests:"
15+
$TestFailures.file.name | select-object -unique
16+
Write-Host "Results:"
17+
Write-Output $TestFailures
18+
exit 1
19+
}
20+
21+
# Else, all passes and exit using exit code 0 indicating a success
22+
else {
23+
Write-Host "All files passed!"
24+
exit 0
25+
}

0 commit comments

Comments
 (0)