Skip to content

Backup Image To PDF repo #299

Backup Image To PDF repo

Backup Image To PDF repo #299

# This is a basic workflow to help you get started with Actions
name: Backup Image To PDF repo
# Controls when the workflow will run
on:
schedule:
# At 00:00 every day
- cron: "0 0 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
sync-image-to-pdf-repo:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
ORIGIN_REPO: [email protected]:yojimbo45/Image-to-PDF-Android.git
BACKUP_REPO: [email protected]:mobiledevpro/image-to-pdf-android.git
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
# Checkout the repo https://github.com/yojimbo45/Image-to-PDF-Android
# - name: Checkout Image-To-PDF-repo
# uses: actions/checkout@v4
# with:
#url: ${{ env.ORIGIN_REPO }}
# ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
# ref: main
# fetch-depth: 0
- name: Create a directory for Image-To-PDF-repo
run: |
mkdir image-to-pdf-repo
# - name: Clone Image-To-PDF Repository
# run: |
# git clone ${BACKUP_REPO} image-to-pdf-repo
- name: Clone Image-To-PDF Repository
uses: actions/checkout@v4
with:
repository: 'yojimbo45/Image-to-PDF-Android'
path: image-to-pdf-repo
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Check the directory
run: |
cd image-to-pdf-repo && ls
- name: Swith remote origin
run: |
echo ${BACKUP_REPO} &&
cd image-to-pdf-repo &&
git remote set-url origin ${BACKUP_REPO}
- name: Delete all branches except master
run: |
git ls-remote --heads ${BACKUP_REPO} | awk -F/ '! /\/master/{print $3}' | xargs -I {} git push ${BACKUP_REPO} --delete --force {} || true
- name: Push all branches to backup repo
run: |
git push origin main:master --force
- name: Push all tags to backup repo
run: |
git push --tags