-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: backup | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * 0" # every sunday at midnight | ||
|
||
concurrency: ${{vars.ZENODO_URL}} | ||
|
||
env: | ||
S3_HOST: ${{vars.S3_HOST}} | ||
S3_BUCKET: ${{vars.S3_BUCKET}} | ||
S3_FOLDER: ${{vars.S3_FOLDER}} | ||
ZENODO_URL: ${{vars.ZENODO_URL}} | ||
S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}} | ||
S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}} | ||
ZENODO_API_ACCESS_TOKEN: ${{secrets.ZENODO_API_ACCESS_TOKEN}} | ||
|
||
jobs: | ||
call: | ||
uses: ./.github/workflows/publish_call.yaml | ||
with: | ||
S3_HOST: ${{vars.S3_HOST}} | ||
S3_BUCKET: ${{vars.S3_BUCKET}} | ||
S3_FOLDER: ${{vars.S3_FOLDER}} | ||
ZENODO_URL: ${{vars.ZENODO_URL}} | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: backup | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
S3_HOST: | ||
required: true | ||
type: string | ||
S3_BUCKET: | ||
required: true | ||
type: string | ||
S3_FOLDER: | ||
required: true | ||
type: string | ||
ZENODO_URL: | ||
required: true | ||
type: string | ||
|
||
concurrency: ${{ZENODO_URL}} | ||
|
||
env: | ||
S3_HOST: ${{inputs.S3_HOST}} | ||
S3_BUCKET: ${{inputs.S3_BUCKET}} | ||
S3_FOLDER: ${{inputs.S3_FOLDER}} | ||
ZENODO_URL: ${{inputs.ZENODO_URL}} | ||
S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}} | ||
S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}} | ||
ZENODO_API_ACCESS_TOKEN: ${{secrets.ZENODO_API_ACCESS_TOKEN}} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: "pip" # caching pip dependencies | ||
- run: pip install -r requirements.txt | ||
- run: | | ||
python scripts/backup.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
|
||
import typer | ||
from dotenv import load_dotenv | ||
from loguru import logger | ||
from utils.s3_client import Client | ||
|
||
_ = load_dotenv() | ||
|
||
|
||
def backup(): | ||
"""backup collection | ||
Returns: | ||
list of folders and file names backed up | ||
""" | ||
client = Client() | ||
content_to_backup = list(client.ls("")) | ||
destination = os.environ["ZENODO_URL"] | ||
logger.error("Backup to '{}': {}", destination, content_to_backup) | ||
return content_to_backup | ||
|
||
|
||
if __name__ == "__main__": | ||
typer.run(backup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters