Skip to content

Commit 87cb09a

Browse files
authored
Multiple files & versions of choice (#4)
1 parent e03626e commit 87cb09a

File tree

6 files changed

+86
-37
lines changed

6 files changed

+86
-37
lines changed

.github/workflows/main.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ jobs:
88

99
runs-on: ubuntu-latest
1010

11+
strategy:
12+
matrix:
13+
files: [ '**/*.bicep', 'sample1.bicep sample2.bicep biceps/sample3.bicep biceps/sample4.bicep' ]
14+
version: [ 'latest', 'v0.3.255', 'v0.2.x' ]
15+
1116
steps:
1217
- name: Checkout the repo
1318
uses: actions/checkout@v2
1419

1520
- name: Run the private action
1621
uses: ./
1722
with:
18-
files: '**/*.bicep'
23+
files: ${{ matrix.files }}
24+
version: ${{ matrix.version }}
1925

2026
- name: Check the result
2127
shell: bash

Dockerfile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Based on the .NET Core self-contained runtime image to run bicep CLI
2-
FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-bionic
2+
FROM mcr.microsoft.com/powershell:lts-ubuntu-18.04
33
WORKDIR /bicep
44

55
LABEL "com.github.actions.name"="Bicep Build"
66
LABEL "com.github.actions.description"="Build ARM templates using the bicep CLI"
77
LABEL "com.github.actions.icon"="copy"
88
LABEL "com.github.actions.color"="orange"
99

10-
LABEL "repository"="http://github.com/aliencube/bicep-actions"
10+
LABEL "repository"="http://github.com/aliencube/bicep-build-actions"
1111
LABEL "homepage"="http://github.com/aliencube"
1212
LABEL "maintainer"="Justin Yoo <[email protected]>"
1313

@@ -17,20 +17,21 @@ RUN apt-get update && apt-get install -y \
1717
curl \
1818
&& rm -rf /var/lib/apt/lists/*
1919

20-
# Fetch the latest Bicep CLI binary
21-
RUN curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
20+
# # Fetch the latest Bicep CLI binary
21+
# RUN curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
22+
# https://github.com/Azure/bicep/releases/download/v0.3.255/bicep-linux-x64
2223

23-
# Mark it as executable
24-
RUN chmod +x ./bicep
24+
# # Mark it as executable
25+
# RUN chmod +x ./bicep
2526

26-
# Add bicep to your PATH (requires admin)
27-
RUN sudo mv ./bicep /usr/local/bin/bicep
27+
# # Add bicep to your PATH (requires admin)
28+
# RUN sudo mv ./bicep /usr/local/bin/bicep
2829

29-
# Verify you can now access the 'bicep' command
30-
RUN bicep --help
31-
# Done!
30+
# # Verify you can now access the 'bicep' command
31+
# RUN bicep --help
32+
# # Done!
3233

33-
ADD entrypoint.sh /entrypoint.sh
34-
RUN chmod +x /entrypoint.sh
34+
ADD entrypoint.ps1 /entrypoint.ps1
35+
RUN chmod +x /entrypoint.ps1
3536

36-
ENTRYPOINT ["/entrypoint.sh"]
37+
ENTRYPOINT ["pwsh", "-File", "/entrypoint.ps1"]

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ This is a GitHub Actions that runs the [bicep CLI](https://github.com/Azure/bice
55

66
## Inputs ##
77

8-
* `files` (**Required**): one or more `.bicep` files to build, delimited by a space. It allows wildcards for recursive build.
8+
* `files` (**Required**): one or more `.bicep` files to build, delimited by a space. eg. file1 file2 file3 ... It allows wildcards for recursive build.
9+
* `version`: Version of the bicep CLI. It can be the exact version (eg. `v0.3.255`), wildcard (eg. `v0.3.x`) or `latest`. If omitted, `latest` is set as default.
910

1011

1112
## Example Usage ##
@@ -16,7 +17,7 @@ This is a GitHub Actions that runs the [bicep CLI](https://github.com/Azure/bice
1617
steps:
1718
# Runs the bicep CLI action - individual files
1819
- name: Run Bicep build
19-
uses: aliencube/bicep-build-actions@v0.1
20+
uses: aliencube/bicep-build-actions@v0.3
2021
with:
2122
files: sample1.bicep sample2.bicep biceps/sample3.bicep biceps/sample4.bicep
2223

@@ -35,7 +36,7 @@ steps:
3536
steps:
3637
# Runs the bicep CLI action - recursive + wildcard
3738
- name: Run Bicep build
38-
uses: aliencube/bicep-build-actions@v0.1
39+
uses: aliencube/bicep-build-actions@v0.3
3940
with:
4041
files: '**/*.bicep'
4142

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ inputs:
1010
files:
1111
description: List of .bicep files to build, delimited by a space. eg) file1 file2 file3 ...
1212
required: true
13+
version:
14+
description: Version of the bicep CLI. It can be the exact version (eg. `v0.3.255`), wildcard (eg. `v0.3.x`) or `latest`. If omitted, `latest` is set as default.
15+
required: false
1316

1417
runs:
1518
using: docker
1619
image: Dockerfile
1720
args:
18-
- ${{ inputs.files }}
21+
- -Files
22+
- ${{ inputs.files }}
23+
- -Version
24+
- ${{ inputs.version }}

entrypoint.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Param(
2+
[string]
3+
[Parameter(Mandatory=$true)]
4+
$Files,
5+
6+
[string]
7+
[Parameter(Mandatory=$false)]
8+
$Version = "latest"
9+
)
10+
11+
if ($Files -eq $null) {
12+
Write-Host "Please provide at least one .bicep file" -ForegroundColor Red -BackgroundColor Yellow
13+
}
14+
15+
$items = Get-ChildItem -Path $($Files -split " ") -Recurse
16+
if (($items -eq $null) -or ($items.Count -eq 0)) {
17+
Write-Host "Please provide at least one .bicep file" -ForegroundColor Red -BackgroundColor Yellow
18+
19+
return
20+
}
21+
22+
# Check Bicep version
23+
$uri = "https://api.github.com/repos/Azure/bicep/releases"
24+
$headers = @{ Accept = "application/vnd.github.v3+json" }
25+
26+
$releases = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
27+
if ($Version -eq "latest") {
28+
$release = ($releases | Select-Object -Property tag_name | Sort-Object -Descending)[0]
29+
} else {
30+
$release = ($releases | Where-Object { $_.tag_name -like $Version.Replace("x", "*") } | Select-Object -Property tag_name | Sort-Object -Descending)[0]
31+
}
32+
33+
$uri = "https://github.com/Azure/bicep/releases/download/$($release.tag_name)/bicep-linux-x64"
34+
35+
# Fetch the given version of Bicep CLI binary
36+
curl -Lo bicep $uri
37+
38+
# Mark it as executable
39+
chmod +x ./bicep
40+
41+
# Add bicep to your PATH (requires admin)
42+
sudo mv ./bicep /usr/local/bin/bicep
43+
44+
# Verify you can now access the 'bicep' command
45+
bicep --help
46+
# Done!
47+
48+
# Build bicep files individually
49+
$items | ForEach-Object {
50+
bicep build $_.FullName
51+
52+
Write-Host "$($_.FullName) -> $($_.FullName.Replace(".bicep", ".json"))"
53+
}

entrypoint.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)