|
| 1 | +--- |
| 2 | +output: github_document |
| 3 | +--- |
| 4 | + |
| 5 | +<!-- README.md is generated from README.Rmd. Please edit that file --> |
| 6 | + |
| 7 | +```{r} |
| 8 | +#| include: FALSE |
| 9 | +knitr::opts_chunk$set( |
| 10 | + collapse = TRUE, |
| 11 | + comment = "#>", |
| 12 | + fig.path = "man/figures/README-", |
| 13 | + out.width = "100%" |
| 14 | +) |
| 15 | +``` |
| 16 | + |
| 17 | +# multideploy <img src="man/figures/multideploy-logo.svg" align="right" height="139" /> |
| 18 | + |
| 19 | +<!-- badges: start --> |
| 20 | +[](https://github.com/coatless-rpkg/multideploy/actions/workflows/R-CMD-check.yaml) |
| 21 | +[](https://lifecycle.r-lib.org/articles/stages.html#experimental) |
| 22 | +<!-- badges: end --> |
| 23 | + |
| 24 | +## Overview |
| 25 | + |
| 26 | +The `multideploy` package provides tools for deploying file changes across multiple GitHub repositories. It's designed to help you manage standardized configurations, CI/CD workflows, and other common files that need to be synchronized across multiple repositories. |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +You can install the development version of `multideploy` from [GitHub](https://github.comcoatless-rpkg/multideploy) with: |
| 31 | + |
| 32 | +```r |
| 33 | +# install.packages("remotes") |
| 34 | +remotes::install_github("coatless-rpkg/multideploy") |
| 35 | +``` |
| 36 | + |
| 37 | +## Authentication |
| 38 | + |
| 39 | +`multideploy` uses the [`gh`](https://github.com/r-lib/gh) package for |
| 40 | +GitHub API authentication and querying. Before using `multideploy`, make sure |
| 41 | +you have a GitHub Personal Access Token (PAT) set up: |
| 42 | + |
| 43 | +```r |
| 44 | +# Set GitHub PAT (or use .Renviron) |
| 45 | +Sys.setenv(GITHUB_PAT = askpass::askpass("What is your GitHub Personal Access Token (PAT)?")) |
| 46 | +``` |
| 47 | + |
| 48 | +It's recommended to store your PAT in your `.Renviron` file rather than in your code. |
| 49 | + |
| 50 | +## Quick Start Example |
| 51 | + |
| 52 | +Here's an example showing how to deploy a standardized CI workflow file to multiple repositories using `multideploy`: |
| 53 | + |
| 54 | +```{r} |
| 55 | +#| label: quick-example |
| 56 | +#| eval: false |
| 57 | +library(multideploy) |
| 58 | +
|
| 59 | +# List repositories in an organization matching a pattern |
| 60 | +repos <- repos("my-organization", filter_regex = "^api-") |
| 61 | +
|
| 62 | +# Deploy a CI workflow file to the selected repositories |
| 63 | +results <- file_deploy( |
| 64 | + source_file = "templates/check-standard.yml", |
| 65 | + target_path = ".github/workflows/R-CMD-check.yaml", |
| 66 | + repos = repos |
| 67 | +) |
| 68 | +
|
| 69 | +# View results |
| 70 | +print(results) |
| 71 | +``` |
| 72 | + |
| 73 | +> [!IMPORTANT] |
| 74 | +> |
| 75 | +> The GitHub PAT used for authentication must have the necessary permissions to |
| 76 | +> access and modify the repositories' workflows. |
| 77 | +
|
| 78 | +## Extended Overview |
| 79 | + |
| 80 | +If you're looking for more detailed examples on how to use `multideploy`, we |
| 81 | +step through the additional features of the package within this section. |
| 82 | + |
| 83 | +### Repository Selection |
| 84 | + |
| 85 | +List and filter repositories across users or organizations: |
| 86 | + |
| 87 | +```{r} |
| 88 | +#| label: repo-listing |
| 89 | +#| eval: false |
| 90 | +# Get all public repositories for a user |
| 91 | +user_repos <- repos("username", type = "public") |
| 92 | +
|
| 93 | +# Get repositories for an organization matching a pattern |
| 94 | +org_repos <- repos("orgname", filter_regex = "^data-") |
| 95 | +
|
| 96 | +# List organizations you have access to |
| 97 | +my_orgs <- orgs() |
| 98 | +``` |
| 99 | + |
| 100 | +### File Deployment |
| 101 | + |
| 102 | +Deploy individual files or sets of files to multiple repositories: |
| 103 | + |
| 104 | +```{r} |
| 105 | +#| label: file-deploy |
| 106 | +#| eval: false |
| 107 | +# Deploy a single file |
| 108 | +file_deploy("local/path/file.R", "remote/path/file.R", repos) |
| 109 | +
|
| 110 | +# Create a mapping of multiple files |
| 111 | +mapping <- file_mapping( |
| 112 | + "local/lint.R" = ".lintr", |
| 113 | + "local/gitignore" = ".gitignore", |
| 114 | + dir = "templates/workflows", |
| 115 | + pattern = "\\.ya?ml$", |
| 116 | + target_prefix = ".github/workflows/" |
| 117 | +) |
| 118 | +
|
| 119 | +# Create pull requests with multiple file changes |
| 120 | +pr_create( |
| 121 | + repos = repos, |
| 122 | + branch_name = "feature/standardize-workflows", |
| 123 | + title = "Standardize CI workflows", |
| 124 | + body = "Implements organization-wide CI workflow standards", |
| 125 | + file_mapping = mapping |
| 126 | +) |
| 127 | +``` |
| 128 | + |
| 129 | +### Dry Run Mode |
| 130 | + |
| 131 | +Preview changes before making them: |
| 132 | + |
| 133 | +```{r} |
| 134 | +#| label: dry-run |
| 135 | +#| eval: false |
| 136 | +# Preview changes without making them |
| 137 | +file_deploy("local/file.R", "remote/file.R", repos, dry_run = TRUE) |
| 138 | +
|
| 139 | +# Preview PR creation |
| 140 | +pr_create(repos, "branch-name", "PR Title", "PR Body", mapping, dry_run = TRUE) |
| 141 | +``` |
| 142 | + |
| 143 | +## License |
| 144 | + |
| 145 | +AGPL (>= 3) |
0 commit comments