Skip to content

Commit 94f30d4

Browse files
author
Mohit Shrivastava
committed
backup-workflow
1 parent d8854fb commit 94f30d4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/repo-backup.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Mirror repo to S3
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
s3Backup:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
# Step to extract the branch name
13+
- name: Extract branch name
14+
id: extract_branch
15+
shell: bash
16+
run: echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})"
17+
18+
# Step to extract just the repository name
19+
- name: Extract repository name
20+
id: extract_repo
21+
shell: bash
22+
run: echo "::set-output name=repo::$(echo ${{ github.repository }} | cut -d'/' -f2)"
23+
24+
- name: S3 Backup
25+
uses: icymojitoo/s3-backup@v1
26+
env:
27+
STORAGE_SERVICE_URL: ${{ secrets.BACKUPS_BUCKET_STORAGE_SERVICE_URL }}
28+
ACCESS_KEY_ID: ${{ secrets.BACKUPS_BUCKET_ACCESS_KEY_ID }}
29+
SECRET_ACCESS_KEY: ${{ secrets.BACKUPS_BUCKET_SECRET_ACCESS_KEY }}
30+
# Use the extracted repository and branch names in the MIRROR_TARGET
31+
MIRROR_TARGET: ${{ secrets.BACKUPS_BUCKET_MIRROR_TARGET }}/${{ steps.extract_repo.outputs.repo }}/${{ steps.extract_branch.outputs.branch }}
32+
with:
33+
args: --overwrite --remove
34+
35+
- name: Notify Discord
36+
uses: icymojitoo/discord-webhook@v1
37+
with:
38+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
39+
content: |
40+
:white_check_mark: **Backup of ${{ steps.extract_repo.outputs.repo }}/${{ steps.extract_branch.outputs.branch }} completed successfully!**

0 commit comments

Comments
 (0)