-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fixpoint/fix-already-exists
✨ Add `overwrite` option to allow overwriting `index.html` and else.
- Loading branch information
Showing
5 changed files
with
59 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
name: 'azblob-generate-static-index' | ||
description: 'Generate index.html for static web hosting on Azure Blob storage' | ||
author: 'fixpoint' | ||
name: "azblob-generate-static-index" | ||
description: "Generate index.html for static web hosting on Azure Blob storage" | ||
author: "fixpoint" | ||
branding: | ||
icon: 'list' | ||
color: 'gray-dark' | ||
icon: "list" | ||
color: "gray-dark" | ||
inputs: | ||
connection-string: | ||
description: 'Connection string' | ||
description: "Connection string" | ||
required: true | ||
container: | ||
description: 'Container name' | ||
description: "Container name" | ||
required: false | ||
default: '$web' | ||
default: "$web" | ||
prefix: | ||
description: 'Prefix for index.html' | ||
description: "Prefix for index.html" | ||
required: true | ||
overwrite: | ||
description: "Allow to overwrite index.html (true/false)" | ||
required: true | ||
default: "false" | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
using: "docker" | ||
image: "Dockerfile" | ||
args: | ||
- ${{ inputs.connection-string }} | ||
- ${{ inputs.container }} | ||
- ${{ inputs.prefix }} | ||
- ${{ inputs.overwrite }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
CONTAINER_STRING=$1 | ||
CONTAINER_NAME=$2 | ||
PREFIX=$3 | ||
OVERWRITE=$4 | ||
|
||
set -Cue | ||
|
||
if [[ -z $CONTAINER_STRING ]]; then | ||
echo "container string is not specified" >&2 | ||
exit 1 | ||
fi | ||
if [[ -z $CONTAINER_NAME ]]; then | ||
echo "container name is not specified" >&2 | ||
exit 1 | ||
fi | ||
if [[ -z $PREFIX ]]; then | ||
echo "prefix is not specified" >&2 | ||
exit 1 | ||
fi | ||
|
||
OPTIONS="" | ||
if [[ $OVERWRITE == "true" ]]; then | ||
OPTIONS=" --overwrite" | ||
fi | ||
|
||
az storage blob list \ | ||
--connection-string $CONTAINER_STRING \ | ||
--container-name $CONTAINER_NAME \ | ||
--prefix $PREFIX/ \ | ||
| jq -r '{"items": [sort_by(.properties.lastModified) | reverse | .[] | select(.name | endswith("/index.html") | not)] }' \ | ||
| mustache /index.html.mustache \ | ||
> index.html | ||
|
||
az storage blob upload \ | ||
--connection-string $CONTAINER_STRING \ | ||
--container-name $CONTAINER_NAME \ | ||
--name $PREFIX/index.html \ | ||
--file index.html \ | ||
$OPTIONS |
This file was deleted.
Oops, something went wrong.