Coder Social home page Coder Social logo

sukanyadas2021 / upload-azure-blob Goto Github PK

View Code? Open in Web Editor NEW

This project forked from github-developer/upload-azure-blob

0.0 0.0 0.0 1.37 MB

Example GitHub action to upload file(s) to Azure Blob Storage

Home Page: https://devblogs.microsoft.com/devops/building-your-first-github-action/

License: MIT License

JavaScript 4.58% TypeScript 95.42%

upload-azure-blob's Introduction

typescript-action status

Upload Blob to Azure Storage

This is an example GitHub action built in TypeScript that uploads file(s) to Azure Blob Storage, a "massively scalable and secure object storage for cloud-native workloads, archives, data lakes, high-performance computing, and machine learning".

Note: this action is meant solely for demonstration purposes. Best viewed together with the accompanying blog post.

For more about GitHub Actions, refer to the documentation.

Pre-reqs

  • Use an existing Azure account or sign up for a free account
  • Make sure you have access to a new or existing resource group, storage account, and container – for example, by following the first few steps of this quickstart
  • Then, configure credentials that can write Azure Storage containers and blobs, like a service principal with the "Storage Blob Data Contributor" role.
az ad sp create-for-rbac 
  --name $SP_NAME
  --sdk-auth
  --role "Storage Blob Data Contributor"
  --scopes /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP_NAME
  • Finally, store these credentials as a secret named AZURE_CREDENTIALS

Usage

Simple example:

# GitHub Actions repository workflow file, e.g .github/workflows/upload.yml

# ...
# previous steps to choose a runner type, prepare files, etc
# ...

- uses: azure/login@v1
  with:
    creds: ${{ secrets.AZURE_CREDENTIALS }}

# Upload `.png`s to Azure Blob Storage
- name: Upload all PNGs to Azure Blob Storage
  id: upload
  uses: github-developer/upload-azure-blob@v1
  with:
    account: octodex
    destination: octocats
    source: '**/*.png'

# Print out the urls to uploaded files
- name: Print URLs
  run: echo $URLS # { ["filename":"hulatocat.png","url":"https://octodex.blob.core.windows.net/octocats/hulatocat.png"] }
  env:
    URLS: ${{ steps.upload.outputs.urls }}

# ...

Inputs

  • account (required): Storage account name, e.g. mystorageaccount
  • destination (required): Name of container to upload blob to, e.g. $web to upload a static website.
  • source (required): Path to file(s) to upload to destination, e.g. . to upload all files in the current directory. Supports globbing, e.g. images/**.png. For more information, please refer to https://www.npmjs.com/package/glob.

Outputs

  • urls: data structure with names and urls to uploaded files

License

MIT

Contributing

Pull requests are welcome! See CONTRIBUTING.md for more.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.