Skip to content

Commit 60bc478

Browse files
authored
Merge pull request #2 from armhil/armhil/implementation
Adding implementation
2 parents 3f705fd + 8fd3cf9 commit 60bc478

File tree

16 files changed

+2833
-0
lines changed

16 files changed

+2833
-0
lines changed

.github/workflows/main.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "main" branch
8+
push:
9+
branches: [ "main" ]
10+
pull_request:
11+
branches: [ "main" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
# Steps represent a sequence of tasks that will be executed as part of the job
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- uses: actions/checkout@v3
27+
28+
# Test using node
29+
- name: Setup Node.js environment
30+
uses: actions/setup-node@v3.3.0
31+
- run: npm ci
32+
- run: npm test
33+
34+
# Runs a single command using the runners shell
35+
- name: Upload Static Content
36+
uses: armhil/azure-blobs-content-uploader@1.0.0
37+
with:
38+
azureBlobConfiguration: ${{ secrets.AZ_BLOB_CONFIGURATION }}
39+
directoriesToUpload: '[{"path": "test/integrationtest-directory", "shouldRecurse": "true" }]'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/**/*

action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Static Content Uploader for Azure Blobs'
2+
description: 'A useful tool for uploading CRA artifacts to Az Blobs'
3+
inputs:
4+
azureBlobConfiguration: # Should be a secret value, with connection strings
5+
description: 'Azure blob configuration'
6+
required: true
7+
fileTypesToUpload: # We may not want to upload all files
8+
description: 'Our static content extensions to Content-Type may be limited for you, use this if you want to extend'
9+
required: true
10+
default: '{ ".html": "text/html", ".pdf": "application/pdf", ".png": "image/png", ".jpg": "image/jpeg", ".svg": "image/svg+xml", ".css": "text/css", ".js": "application/x-javascript" }'
11+
directoriesToUpload: # List of directories to upload
12+
description: 'List of directories to upload, relative paths only'
13+
required: true
14+
runs:
15+
using: 'node16'
16+
main: 'index.js'

index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const core = require('@actions/core');
2+
const fileUtils = require('./src/fileSystemUtils');
3+
const azUploadUtils = require('./src/azUploadUtils');
4+
5+
try {
6+
/**
7+
* File types to upload should look like
8+
* { ".html": "text/html" }
9+
*/
10+
const fileTypesToUpload = JSON.parse(core.getInput('fileTypesToUpload'));
11+
/**
12+
* Directories to upload should look like
13+
* [
14+
* { path: "", shouldRecurse: "" }
15+
* ]
16+
*/
17+
const directoriesToUpload = JSON.parse(core.getInput('directoriesToUpload')) || [];
18+
let filesToUpload = [];
19+
directoriesToUpload.forEach(t => {
20+
filesToUpload = filesToUpload.concat(fileUtils.getFilesForUpload(t.path, t.shouldRecurse, Object.keys(fileTypesToUpload)));
21+
});
22+
/**
23+
* Azure Blob Configurations should look like
24+
* [
25+
* { connectionString: "", container: "", path: "" }
26+
* ]
27+
*/
28+
const azureBlobConfiguration = JSON.parse(core.getInput('azureBlobConfiguration'));
29+
azUploadUtils.uploadAll(azureBlobConfiguration, filesToUpload, fileTypesToUpload);
30+
}
31+
catch (error) {
32+
core.setFailed(error.message);
33+
}

0 commit comments

Comments
 (0)