GitHub Action
Backup Github to AWS S3
v1.0.0
Latest version
This action backs up GitHub repositories to an Amazon S3 bucket.
Required GitHub token (Personal Access Token with repo
scope to access private repositories).
Required AWS Access Key ID.
Required AWS Secret Access Key.
Required AWS Region.
Required S3 bucket name.
GitHub organization name (optional). Provide this to back up an organization's repositories. If not provided, the action will back up repositories for the user associated with the provided GitHub token.
- Go to your GitHub account settings.
- Navigate to "Developer settings" > "Personal access tokens".
- Generate a new token with the
repo
scope. - Copy the token.
- Go to your repository's settings.
- Navigate to "Secrets and variables" > "Actions".
- Add the following secrets:
GH_TOKEN
: The GitHub Personal Access Token generated in Step 1.AWS_ACCESS_KEY_ID
: Your AWS Access Key ID.AWS_SECRET_ACCESS_KEY
: Your AWS Secret Access Key.AWS_DEFAULT_REGION
: Your AWS region.S3_BUCKET
: The name of your S3 bucket.GH_ORG_NAME
: (Optional) The GitHub organization name if you are backing up an organization's repositories.
Create a workflow file in your repository (e.g., .github/workflows/backup.yml
) with the following content:
name: Backup GitHub Repos to S3
on:
schedule:
- cron: '0 2 * * *' # Runs every day at 2 AM UTC
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run backup action
uses: your-username/[email protected]
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Ensure this is the correct PAT with `repo` scope
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
GH_ORG_NAME: ${{ secrets.GH_ORG_NAME }} # Only required if backing up an organization's repositories