All Projects → BetaHuhn → do-spaces-action

BetaHuhn / do-spaces-action

Licence: MIT license
📦Upload directories/files to DigitalOcean Spaces via GitHub Actions. Supports package/library versioning.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to do-spaces-action

Nginxconfig.io
⚙️ NGINX config generator on steroids 💉
Stars: ✭ 14,983 (+49843.33%)
Mutual labels:  digitalocean, cdn
DigitalOcean-Spaces-Sync
This WordPress plugin syncs your media library with DigitalOcean Spaces Container.
Stars: ✭ 46 (+53.33%)
Mutual labels:  digitalocean, digitalocean-spaces
ghaction-dump-context
GitHub Action composite to dump context
Stars: ✭ 30 (+0%)
Mutual labels:  actions
gh-actions-html-table-generator
Read from a json file and write to the README
Stars: ✭ 29 (-3.33%)
Mutual labels:  actions
pr-compliance-action
Check PR for compliance on title, linked issues, and files changed
Stars: ✭ 151 (+403.33%)
Mutual labels:  actions
GeoLite2-City
GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 170 (+466.67%)
Mutual labels:  cdn
Hacktober-2019
Repo for TOM members dedicated for the Hacktober fest of 2019 (6th edition), this repo is here to encourage open source learning and sharing and enhance git/github using abilities.
Stars: ✭ 16 (-46.67%)
Mutual labels:  digitalocean
k6-action
k6 is now available as a GitHub Action
Stars: ✭ 64 (+113.33%)
Mutual labels:  actions
setup-meteor
Set up your GitHub Actions workflow with a specific version of Meteor.js
Stars: ✭ 17 (-43.33%)
Mutual labels:  actions
flex-originals
🎧 A video and audio streaming web application
Stars: ✭ 36 (+20%)
Mutual labels:  cdn
setup-lazarus
Set up your GitHub Actions workflow with a specific version of Lazarus
Stars: ✭ 29 (-3.33%)
Mutual labels:  actions
CloudFrontier
Monitor the internet attack surface of various public cloud environments. Currently supports AWS, GCP, Azure, DigitalOcean and Oracle Cloud.
Stars: ✭ 102 (+240%)
Mutual labels:  digitalocean
fastly
Fastly API client for Node.js
Stars: ✭ 70 (+133.33%)
Mutual labels:  cdn
python-doctl
A Python wrapper for the Digital Ocean CLI utility — doctl.
Stars: ✭ 49 (+63.33%)
Mutual labels:  digitalocean
gulp-upload-qcloud
腾讯云 cos 静态资源上传 gulp 插件
Stars: ✭ 18 (-40%)
Mutual labels:  cdn
innersource-crawler
This project creates a repos.json that can be utilized by the SAP InnerSource Portal.
Stars: ✭ 24 (-20%)
Mutual labels:  actions
action-my-broken-link-checker
A GitHub Action for checking broken links
Stars: ✭ 32 (+6.67%)
Mutual labels:  actions
Localizr
Localizr is a Tool that handles and automates the generation of localization files for IOS and Android so there will be only one source of truth for all of your localization strings.
Stars: ✭ 33 (+10%)
Mutual labels:  actions
qiniu-auto-cert
七牛 CDN 证书自动化工具
Stars: ✭ 20 (-33.33%)
Mutual labels:  cdn
nomad-droplets-autoscaler
DigitalOcean Droplets target plugin for HashiCorp Nomad Autoscaler
Stars: ✭ 42 (+40%)
Mutual labels:  digitalocean

DigitalOcean Spaces Action

Build GitHub David

Upload directories/files to DigitalOcean Spaces via GitHub Actions.

👋 Introduction

Use do-spaces-action to deploy a file or directory to your DigitalOcean Space with GitHub Actions. This can be used to host your static site, or as an self-hosted alternative to something like JSDelivr for serving your JS files/library via a CDN. do-spaces-action can also automatically grab the version number from the package.json and use it to host multiple versions at once (more info below).

Features

📚 Usage

Create a .yml file in your .github/workflows folder (you can find more info about the structure in the GitHub Docs):

.github/workflows/upload.yml

name: Upload to DO Spaces
on:
  push:
    branches:
      - main
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@master
      - uses: BetaHuhn/do-spaces-action@v2
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: src

More info on how to specify what files to upload where below.

Action Versioning

To always use the latest version of the action add the latest tag to the action name like this:

uses: BetaHuhn/do-spaces-action@latest

If you want to make sure that your workflow doesn't suddenly break when a new major version is released, use the v2 tag instead (recommended usage):

uses: BetaHuhn/do-spaces-action@v2

With the v2 tag you will always get the latest non-breaking version which will include potential bug fixes in the future. If you use a specific version, make sure to regularly check if a new version is available, or enable Dependabot.

⚙️ Action Inputs

Here are all the inputs do-spaces-action takes:

Key Value Required Default
access_key Your DigitalOcean access key - more info Yes N/A
secret_key Your DigitalOcean secret key - more info Yes N/A
space_name The name of your DigitalOcean Space Yes N/A
space_region The region of your DigitalOcean Space Yes N/A
source Path to the source file or folder (what you want to upload) - more info Yes N/A
out_dir Path to the output directory in your Space (where you want to upload to) - more info No /
versioning Enable versioning (either set it to true or specify path to package.json) - more info No false
cdn_domain Custom domain pointing to your CDN endpoint - more info No N/A
permission Access permissions of the uploaded files - more info No public-read

Authentication

In order to access your DigitalOcean Space, you have to specify a few required values. The access_key and secret_key can be generated on your DigitalOcean Account Page. The space_name and space_region are different based on your created Space.

It is recommended to set them as Repository Secrets.

Source

The source input can either point to a single file or to a whole directory which should be uploaded. The path is relative to the root of your repository.

See example

Output directory

By default do-spaces-action will upload all files to the root of your Space. You can specify a different output directory with the out_dir input.

See example

Versioning

do-spaces-action also supports versioning and can detect the current version from your package.json and then upload the file/s to a folder with the version as the name. Let's suppose you bump the version of your project from v2.3.0 to v2.4.0. Both versions would remain on your Space, under different paths:

  • v2.3.0 -> https://SPACE.fra1.digitaloceanspaces.com/js/v2.3.0/index.min.js
  • v2.4.0 -> https://SPACE.fra1.digitaloceanspaces.com/js/v2.4.0/index.min.js

The most recent version will be available with the latest tag:

  • latest -> https://SPACE.fra1.digitaloceanspaces.com/js/latest/index.min.js

The versioning parameter can be set to true/false, or a string representing the path to the package.json file.

See example

CDN Domain

Instead of outputting the normal DigitalOcean domain https://SPACE.fra1.digitaloceanspaces.com/, you can also specify your custom CDN domain with cdn_domain.

Note: https://SPACE.REGION.digitaloceanspaces.com/ is still used to connect to your Space, do-spaces-action will just use it when logging it and assigning it to the action output variable output_url.

See example

File permissions

By default all uploaded files have their access permission set to public-read. This means that anyone can access them via their own Space URL. If you want to block public access, you can set permission to private.

📖 Examples

Here are a few examples to help you get started!

Basic Example

This example will run everytime you create a new release and then upload all files and directories in the src folder to the root of your Space.

name: Upload to DO Spaces
on:
  release:
    types: [created]
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: BetaHuhn/do-spaces-action@v2
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: src

Custom output path

This example will run everytime you create a new release and then upload the src directory to the dist folder on your Space.

name: Upload to DO Spaces
on:
  release:
    types: [created]
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: BetaHuhn/do-spaces-action@v2
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: src
          out_dir: dist

Single file upload

This example will run everytime you create a new release and then upload the file path/to/file.js to the root of your Space.

name: Upload to DO Spaces
on:
  release:
    types: [created]
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: BetaHuhn/do-spaces-action@v2
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: path/to/file.js

Use package.json version

This example will run everytime you create a new release and then upload the file dist/index.min.js to both the latest and vX.X.X folder in the js directory in your Space.

name: Upload to DO Spaces
on:
  release:
    types: [created]
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: BetaHuhn/do-spaces-action@v2
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: dist/index.min.js
          out_dir: js
          versioning: true

The versioning parameter can be set to true/false, or a string representing the path to the package.json file.

Specify a custom CDN domain

name: Upload to DO Spaces
on:
  release:
    types: [created]
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: BetaHuhn/do-spaces-action@v2
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: src
          cdn_domain: cdn.example.com

Create deployment on GitHub

do-spaces-action can be perfectly intergrated with Actions like Create Deployment Status Update to create a deployment once all files are uploaded:

name: Upload to DO Spaces
on:
  release:
    types: [created]
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: altinukshini/deployment-action@releases/v1
        name: start deployment
        id: deployment
        with:
          token: ${{ secrets.GITHUB_TOKEN}}
          description: Uploading files to DO Spaces
          environment: production

      - uses: BetaHuhn/do-spaces-action@v2
        name: upload to spaces
        id: spaces
        with:
          access_key: ${{ secrets.ACCESS_KEY}}
          secret_key: ${{ secrets.SECRET_KEY }}
          space_name: ${{ secrets.SPACE_NAME }}
          space_region: ${{ secrets.SPACE_REGION }}
          source: src
          out_dir: dist
          versioning: true

      - name: update deployment status
        if: always()
        uses: altinukshini/deployment-status@releases/v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          state: ${{ job.status }}
          deployment_id: ${{ steps.deployment.outputs.deployment_id }}
          environment_url: ${{steps.spaces.outputs.output_url}}
          description: "Successfully uploaded files to DO Spaces"

Here's how that will look on your Repo:

Deployment preview

📝 To do

Here is what's currently planned for do-spaces-action:

  • Different environments: add the option to change the upload path pased on the environment (staging/production)

If you have an idea, feel free to open an issue!

💻 Development

Issues and PRs are very welcome!

The actual source code of this library is in the src folder.

  • run yarn lint or npm run lint to run eslint.
  • run yarn start or npm run start to run the Action locally.
  • run yarn build or npm run build to produce a production version in the dist folder.

About

This project was developed by me (@betahuhn) in my free time. If you want to support me:

Donate via PayPal

ko-fi

📄 License

Copyright 2021 Maximilian Schiller

This project is licensed under the MIT License - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].