-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cahaseler
committed
Mar 25, 2021
0 parents
commit 45cf61a
Showing
4 changed files
with
99 additions
and
0 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
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"] |
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,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 | ||
``` |
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,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" |
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,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 |