Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cahaseler committed Mar 25, 2021
0 parents commit 45cf61a
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/azure-cli

LABEL "com.github.actions.name"="azure-fileshare-upload"
LABEL "com.github.actions.description"="Uploads folders to Azure File Share"
LABEL "com.github.actions.icon"="arrow-up"
LABEL "com.github.actions.color"="green"
LABEL "repository"="https://github.com/cahaseler/azure-fileshare-upload"
LABEL "homepage"="https://github.com/cahaseler/azure-fileshare-upload"
LABEL "maintainer"="Craig Haseler <[email protected]>"

ADD entrypoint.sh /entrypoint.sh
RUN chmod +x entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# GitHub Action to Upload Directories to Azure FileShare

This action uses the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) to upload a directory of your choice to your Azure File Storage.

## Usage

### Example

Place in a `.yml` file in your `.github/workflows` folder.

```yaml
name: Upload To Azure FileShare
on:
push:
branches:
- master
jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cahaseler/[email protected]
with:
account_name: storageaccount
account_key: ${{secrets.ACCOUNT_KEY}}
share_name: azure-fileshare
source_dir: config
```
22 changes: 22 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Azure File Share Upload"
author: "Craig Haseler <[email protected]>"
description: "Uploads folders to Azure File Share"
branding:
icon: "arrow-up"
color: "green"
inputs:
account_name:
description: "The storage account name"
required: true
account_key:
description: "The storage account key. Make sure to treat this as a secret"
required: true
share_name:
description: "The name of the fileshare you are uploading to"
required: true
source_dir:
description: "The name of the directory in your Github you want to replace the contents of the fileshare with. Defaults to the whole repository."
required: false
runs:
using: "docker"
image: "Dockerfile"
35 changes: 35 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -e

if [ -z "$INPUT_ACCOUNT_NAME" ]; then
echo "Sccount name is not set. Quitting."
exit 1
fi

if [ -z "$INPUT_ACCOUNT_KEY" ]; then
echo "Sccount name is not set. Quitting."
exit 1
fi

if [ -z "$INPUT_SHARE_NAME" ]; then
echo "Share name is not set. Quitting."
exit 1
fi


$FILES=/
if [ -z "$INPUT_SOURCE_DIR" ]; then
echo "Source name is not set. Running on entire repo."
$FILES=$INPUT_SOURCE_DIR
fi

for f in $FILES
do
echo "Uploading $f..."
az storage file upload \
--account-name $INPUT_ACCOUNT_NAME
--account-key $INPUT_ACCOUNT_KEY
--destination $INPUT_SHARE_NAME
--source $FILES
done

0 comments on commit 45cf61a

Please sign in to comment.