Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Test using node
- name: Setup Node.js environment
uses: actions/setup-node@v3.3.0
- run: npm ci
- run: npm test

# Runs a single command using the runners shell
- name: Upload Static Content
uses: armhil/azure-blobs-content-uploader@1.0.0
with:
azureBlobConfiguration: ${{ secrets.AZ_BLOB_CONFIGURATION }}
directoriesToUpload: '[{"path": "test/integrationtest-directory", "shouldRecurse": "true" }]'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/**/*
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Static Content Uploader for Azure Blobs'
description: 'A useful tool for uploading CRA artifacts to Az Blobs'
inputs:
azureBlobConfiguration: # Should be a secret value, with connection strings
description: 'Azure blob configuration'
required: true
fileTypesToUpload: # We may not want to upload all files
description: 'Our static content extensions to Content-Type may be limited for you, use this if you want to extend'
required: true
default: '{ ".html": "text/html", ".pdf": "application/pdf", ".png": "image/png", ".jpg": "image/jpeg", ".svg": "image/svg+xml", ".css": "text/css", ".js": "application/x-javascript" }'
directoriesToUpload: # List of directories to upload
description: 'List of directories to upload, relative paths only'
required: true
runs:
using: 'node16'
main: 'index.js'
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const core = require('@actions/core');
const fileUtils = require('./src/fileSystemUtils');
const azUploadUtils = require('./src/azUploadUtils');

try {
/**
* File types to upload should look like
* { ".html": "text/html" }
*/
const fileTypesToUpload = JSON.parse(core.getInput('fileTypesToUpload'));
/**
* Directories to upload should look like
* [
* { path: "", shouldRecurse: "" }
* ]
*/
const directoriesToUpload = JSON.parse(core.getInput('directoriesToUpload')) || [];
let filesToUpload = [];
directoriesToUpload.forEach(t => {
filesToUpload = filesToUpload.concat(fileUtils.getFilesForUpload(t.path, t.shouldRecurse, Object.keys(fileTypesToUpload)));
});
/**
* Azure Blob Configurations should look like
* [
* { connectionString: "", container: "", path: "" }
* ]
*/
const azureBlobConfiguration = JSON.parse(core.getInput('azureBlobConfiguration'));
azUploadUtils.uploadAll(azureBlobConfiguration, filesToUpload, fileTypesToUpload);
}
catch (error) {
core.setFailed(error.message);
}
Loading