-
Notifications
You must be signed in to change notification settings - Fork 3
146 lines (121 loc) · 4.44 KB
/
drat--insert-package.yaml
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
# READ-ONLY FILE
#
# Original file resides in r-hyperspec/pkg-skelton.
# DO NOT EDIT in any other repo as these changes will be overwritten.
# Edit at r-hyperspec/pkg-skelton, then push there and
# this file will be deployed to the other repos.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NOTE 1:
# This script automatically detects the repository in which it is run.
# No edits are needed except in the "Install Dependencies" section where
# one may need to install additional packages according to the needs.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NOTE 2:
# Each "- name:" task below starts from the same directory, which is:
# /home/runner/work/${{ REPOSITORY_NAME }}/${{ REPOSITORY_NAME }}
# e.g.:
# /home/runner/work/hyperSpec/hyperSpec
# Each task is run in its own shell starting from this directory.
# This means you have to navigate to the desired directory for each task.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NOTE 3:
# If more than one branch given to trigger the workflow,
# one may stomp on the other during deployment, so use only one branch.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on:
workflow_dispatch:
push:
branches: [develop, auto-update-test]
schedule:
# (see https://crontab.guru)
- cron: "10 3 * */2 WED"
name: Publish to pkg-repo (drat)
jobs:
drat:
if: ${{ github.event.repository.name }} != "pkg-skeleton"
runs-on: ${{ matrix.config.os }}
name: "drat: ${{ matrix.config.os }} (R-${{ matrix.config.r }})"
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
# - {os: macOS-latest, r: 'release'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
REPO: ${{ github.event.repository.name }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CACHE_VERSION: 1
steps:
- uses: actions/checkout@v3
- name: Info
run: |
echo "GitHub actor: ${{ github.actor }}"
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
extra-repositories: "https://r-hyperspec.github.io/pkg-repo/"
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::drat, any::devtools, local::.
needs: check
- name: "Install roxygen2==7.2.3"
run: |
remotes::install_version("roxygen2", "7.2.3")
shell: Rscript {0}
- name: Roxygenize
shell: Rscript {0}
run: |
roxygen2::roxygenize()
- name: Build source package
shell: Rscript {0}
run: |
dir.create("check", showWarnings = FALSE)
devtools::build(path = "check")
# Above are the steps to build package
# Below are the steps to deploy to pkg-repo
- name: Configure git
# The following configure step is from
# https://stackoverflow.com/a/60548651/633251
env:
TOKEN: ${{ secrets.DEPLOY_TOKEN }}
run: |
git config --global url."https://${TOKEN}:[email protected]/".insteadOf "https://github.com/"
git config --global user.email "[email protected]"
git config --global user.name "${REPO} Deploy Bot"
- name: Drat -- clone r-hyperspec/pkg-repo
if: success()
run: |
rm -rf tmp-pkg-repo-dir
git clone https://github.com/r-hyperspec/pkg-repo.git tmp-pkg-repo-dir
cd tmp-pkg-repo-dir
git checkout gh-pages
- name: Drat -- insert
if: success()
shell: Rscript {0}
run: |
targz <- list.files(
path = "check",
pattern = "\\.tar\\.gz",
full.names = TRUE
)
drat::insertPackage(
file = targz,
repodir = "tmp-pkg-repo-dir",
action = "archive"
)
- name: Drat -- commit and push
if: success()
run: |
cd tmp-pkg-repo-dir
git add *
# .tar.gz files are globally blocked (git ignored) by git,
# must add manually and force it
git add -f *.tar.gz
git commit -m "Automated deploy from ${REPO}"
git push origin gh-pages