Skip to content

A GitHub action to mirror a repository to a Cloudflare R2 bucket.

License

Notifications You must be signed in to change notification settings

JoseMoranUrena523/r2-backup

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R2 Backup

GitHub Marketplace

A GitHub action to mirror a repository to a Cloudflare R2 bucket.

Usage

This example will mirror your repository to an R2 bucket called repo-backup-bucket and at the optional key /at/some/path. Objects at the target will be overwritten, and extraneous objects will be removed. This default usage keeps your R2 backup in sync with GitHub.

    - name: R2 Backup
      uses: JoseMoranUrena523/[email protected]
      env:
        ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
        SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS_KEY }}
        ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
        BUCKET_NAME: repo-backup-bucket/at/some/path
      with:
        args: --overwrite --remove

R2 Backup uses the mirror command of MinIO Client. Additional arguments may be passed to the action via the args parameter.

Secrets and environment variables

The following variables may be passed to the action as secrets or environment variables. ACCOUNT_ID, for example, if considered sensitive should be passed as a secret.

  • ACCESS_KEY_ID (required) - Your R2 Access Key ID, can be found here.
  • SECRET_ACCESS_KEY (required) - Your R2 Secret Access Key, can be found here.
  • ACCOUNT_ID (required) - Your Cloudflare Account ID, can be found here.
  • BUCKET_NAME (required) - The name of your R2 bucket, and optionally, the path where you want it to be.

API Key Permissions

The API key needs to have the permission Object Read and Write in order for this Action to work properly.

Complete workflow example

The workflow below filters push events for the main branch before mirroring to R2.

name: R2 Backup
on:
  push:
    branches:
      - main
jobs:
  r2Backup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: R2 Backup
        uses: JoseMoranUrena523/[email protected]
        env:
          ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
          BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
          SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS_KEY }}
          ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
        with:
          args: --overwrite --remove

License

Apache License 2.0

About

A GitHub action to mirror a repository to a Cloudflare R2 bucket.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 52.4%
  • Shell 47.6%