-
Notifications
You must be signed in to change notification settings - Fork 18
103 lines (103 loc) · 3.67 KB
/
pr-commands.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
on:
issue_comment:
types: [created]
name: Commands
jobs:
document:
if: startsWith(github.event.comment.body, '/document')
name: document
# macos is actually better here due to native binary packages
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/pr-fetch@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@master
with:
install-r: false
- name: Configure Git identity
run: |
env | sort
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
shell: bash
- name: Install dependencies
run: |
install.packages(c("remotes", "roxygen2"), type = "binary")
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
- name: Document
run: |
roxygen2::roxygenise()
shell: Rscript {0}
- name: commit
run: |
if [ -n "$(git status --porcelain man/ NAMESPACE)" ]; then
git add man/ NAMESPACE
git commit -m 'Document'
fi
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
style:
if: startsWith(github.event.comment.body, '/style')
name: style
# macos is actually better here due to native binary packages
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/pr-fetch@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@master
with:
install-r: false
- name: Configure Git identity
run: |
env | sort
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
shell: bash
- name: Install dependencies
run: |
install.packages(c("styler", "roxygen2"), type = "binary")
shell: Rscript {0}
- name: Style
run: |
styler::style_pkg(strict = FALSE)
shell: Rscript {0}
- name: commit
run: |
if [ -n "$(git status --porcelain '*.R' '*.Rmd')" ]; then
git add '*.R' '*.Rmd'
git commit -m 'Style'
fi
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
merge:
if: startsWith(github.event.comment.body, '/merge')
name: merge
runs-on: ubuntu-22.04
steps:
- name: Create and merge pull request
run: |
set -exo pipefail
PR_DETAILS=$( curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} )
echo "$PR_DETAILS" | jq .
PR_BASE=$(echo "$PR_DETAILS" | jq -r .base.ref)
PR_HEAD=$(echo "$PR_DETAILS" | jq -r .head.ref)
PR_URL=$(curl -s -X POST --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --data '{ "head": "'$PR_BASE'", "base": "'$PR_HEAD'", "title": "Merge back PR target branch", "body": "Target: #${{ github.event.issue.number }}" }' https://api.github.com/repos/${{ github.repository }}/pulls | jq -r .url )
echo $PR_URL
# Merging here won't run CI/CD
# curl -s -X PUT --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL/merge
# A mock job just to ensure we have a successful build status
finish:
runs-on: ubuntu-22.04
steps:
- run: true