Giter VIP home page Giter VIP logo

multi_file_bandit's Introduction

dobbelina/multi_file_bandit@main

This GitHub Action copies files or folders from the current repository to a location in another repository

  Inspiration from @dmnemec
+ Uses rsync exclusively with full access to it's switches.
+ The rsync_option: makes it very versatile
+ with many configuration settings possible. 
+ If rsync_option: is not used it defaults to "-avrh"
! Use with caution!, test with –dry-run before actual commit.

+ Multiple source files/directories separated by comma
+ "file1.txt,file2.txt" or '"file 1.txt","file 2.txt"'
+ if there are spaces in the file/folder name(s)

+ Use ${{ github.event.head_commit.message }} to 
+ preserve the original commit message.

+ git-lfs support.

Important Behavioural Notes of rsync1.

Example Workflow

name: Push Files

on: push

jobs:
  copy-files:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Push test folder & 1 file
        uses: dobbelina/multi_file_bandit@main
        env:
          API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
        with:
          source_file: "My_Folder/,Another_Folder/test.txt"
          destination_repo: "dobbelina/release-test"
          destination_folder: "test-dir" # Omit if destination root
          user_email: "[email protected]"
          user_name: "dobbelina"
          commit_message: ${{ github.event.head_commit.message }}
          rsync_option: "-avrh --delete" # Deletes any files in the 
                                         # destination that is not
                                         # present in the source 

Variables

The API_TOKEN_GITHUB needs to be set in the Secrets section of your repository options. You can retrieve the API_TOKEN_GITHUB here (set the repo permissions). Fine-grained personal access tokens are much more secure as you can set access to only choosen repositories, You need Actions & Contents set to Access: Read and write & Metadata Access: Read-only

  • source_file: The file(s) or directory/directories to be moved. Uses the same syntax as the rsync command. Include the path for any files not in the repositories root directory. Multiple source files/directories separated by comma "file1.txt,file2.txt" or '"file 1.txt","file 2.txt"' if there are spaces in the file/folder name(s)
  • destination_repo: The repository to place the file or directory in.
  • destination_folder: [optional] The folder in the destination repository to place the file in, if not the root directory.
  • user_email: The GitHub user email associated with the API token secret.
  • user_name: The GitHub username associated with the API token secret.
  • destination_branch: [optional] The branch of the source repo to update, if not "main" branch is used.
  • destination_branch_create: [optional] A branch to be created with this commit, defaults to commiting in destination_branch
  • commit_message: [optional] A custom commit message for the commit. Defaults to Update from https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA} use ${{ github.event.head_commit.message }} to preserve the original commit message.
  • rsync_option: [optional] Full access to rsync's switches, if not used it defaults to "-avrh"
  • retry_attempts: [optional] Retry attempts if pushing commit failed, if not used it defaults to 10
  • git_server: [optional] Git server host, default github.com

Behavioural Notes

Footnotes

  1. Source_Folder rsync will copy the folder.
    Source_Folder/ with a trailing slash rsync will only copy the contents of the folder.
    Source_Folder/* with a trailing slash and an asterisk rsync will only copy the contents
    of the folder but without any hidden files or hidden subfolders.
    The asterisk * will expand all files in Source_Folder/* except the files and subfolders whose name starts with a dot (hidden files or hidden subfolders).

multi_file_bandit's People

Contributors

dobbelina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.