A GitHub action for exposing the MinIO Client to your workflow for all your cheapo S3 needs
This example will create a S3 bucket called testruction
at service url https://play.min.io
and set the download
policy for it.
- name: Create a bucket
uses: zalari/action-mc@master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MC_URL: https://play.min.io
MC_ALIAS: play
with:
args: mb create play/testruction -p
- name: Set anonymous download policy on bucket
uses: zalari/action-mc@master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MC_URL: https://play.min.io
MC_ALIAS: minio
with:
args: policy set download play/testruction
It is just a wrapper for the MinIO Client.
Actual arguments are passed to the action via the args
parameter.
The following variables may be passed to the action as secrets or environment variables.
AWS_ACCESS_KEY_ID
(required) - The storage service access key id.AWS_SECRET_ACCESS_KEY
(required) - The storage service secret access key.MC_ALIAS
- The mc config host alias. Defaults tos3
MC_URL
- The URL to the object storage service. Defaults tohttps://s3.amazonaws.com
for Amazon S3.MC_API_SIGNATURE
- The api signature to use for creating the host config. Defaults toS3v4
, can alternativelyS3v2
.MC_BUCKET_LOOKUP
- The bucket lookup to use for creating the host config. Defaults toauto
, can bedns
orpath
as well.
The workflow copies everything from a dist
dir to a newly dynamically generated bucket from the branch name with anonymous download policy set. Also known as poor man's netlify.
name: Poor man's netlify static site deployment
on:
push:
branches:
- master
jobs:
publish-to-public-bucket:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create test data
run: mkdir dist && uptime > dist/uptime.txt
# taken from -> https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions#comment102508135_58034787
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
id: extract_branch
- name: Create a bucket from branch name
uses: zalari/action-mc@master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MC_URL: https://play.min.io
MC_ALIAS: play
with:
args: mb create play/testruction-${{ steps.extract_branch.outputs.branch }} -p
- name: Set anonymous download policy on bucket
uses: zalari/action-mc@master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MC_URL: https://play.min.io
MC_ALIAS: minio
with:
args: policy set download play/testruction-${{ steps.extract_branch.outputs.branch }}
- name: Upload dist to public bucket
uses: zalari/action-mc@master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MC_URL: https://play.min.io
MC_ALIAS: minio
with:
args: cp -r dist/ play/testruction-${{ steps.extract_branch.outputs.branch }}