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