Skip to content

Commit

Permalink
update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ntluong95 committed May 16, 2024
1 parent f5afe04 commit 88f683a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 13 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/create_pr_on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Create Translation Branches and PRs

on:
pull_request:
types: [opened, reopened, synchronize]


jobs:
create_translation_branches:
if: startsWith(github.head_ref, 'handbook_v') && endsWith(github.head_ref, '_en')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Git
run: |
git config --global user.name 'ntluong95'
git config --global user.email '[email protected]'
- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install -y gh
- name: Create language branches and PRs
run: |
LANGS=("fr" "es" "vn" "jp" "tr" "pt" "ru")
PR_BRANCH="${{ github.head_ref }}"
VERSION_SUFFIX="${PR_BRANCH#handbook_}"
BASE_BRANCH="main"
for lang in "${LANGS[@]}"; do
NEW_BRANCH="handbook_${VERSION_SUFFIX/_en/_$lang}"
# Check if the branch already exists
if ! git rev-parse --verify --quiet "${NEW_BRANCH}"; then
git checkout -b "${NEW_BRANCH}"
else
git checkout "${NEW_BRANCH}"
git pull "${PR_BRANCH}" "${NEW_BRANCH}" --rebase
fi
git fetch origin "${NEW_BRANCH}"
git push origin "${NEW_BRANCH}"
gh pr create --base $BASE_BRANCH --head $NEW_BRANCH --title "Handbook ${VERSION_SUFFIX/_en/} $lang" --body "Automated pull request for $lang handbook version ${VERSION_SUFFIX/_en/}"
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}




15 changes: 15 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### 🛠 Changes being made

Describe the general changes in this PR.
Provide links to each commit in the **List of changes**.




### 🏎 List of changes

- [ ] Please do this change [commit #1]

- [ ] Please do this change [commit #2]

- [ ] Please do this change [commit #3]
41 changes: 28 additions & 13 deletions .github/workflows/render_book_on_pr.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
name: Render Book on PR to Main

on:
pull_request: # change to push later
pull_request_target:
types: [closed]
branches:
- main

jobs:
check-merged:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'handbook_update')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

build-and-render:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'handbook_update')
runs-on: ubuntu-latest
needs: [check-merged] # Ensure this runs only after the check-merged job completes
runs-on: ubuntu-latest
steps:
- name: Check out repository
Expand All @@ -22,19 +35,21 @@ jobs:
- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Install R Packages
- name: Restore R package from renv
run: |
Rscript -e '
if (!requireNamespace("pacman", quietly = TRUE)) install.packages("pacman")
pacman::p_load(
"tidyverse", "googlesheets4", "learnr", "swirl", "here", "rio", "openxlsx",
"pacman", "renv", "remotes", "linelist", "naniar", "janitor", "gtsummary",
"rstatix", "broom", "lmtest", "easystats", "epicontacts", "EpiNow2",
"EpiEstim", "projections", "incidence2", "i2extras", "epitrix", "distcrete",
"cowplot", "RColorBrewer", "ggnewscale", "DiagrammeR", "gghighlight", "ggrepel",
"plotly", "gganimate", "sf", "tmap", "OpenStreetMap", "spdep", "rmarkdown",
"reportfactory", "officer", "flexdashboard", "shiny", "knitr", "flextable",
"ggtree", "ape", "treeio", "babelquarto", "babeldown")'
install.packages("renv")
renv::restore()
# Rscript -e '
# if (!requireNamespace("pacman", quietly = TRUE)) install.packages("pacman")
# pacman::p_load(
# "tidyverse", "googlesheets4", "learnr", "swirl", "here", "rio", "openxlsx",
# "pacman", "renv", "remotes", "linelist", "naniar", "janitor", "gtsummary",
# "rstatix", "broom", "lmtest", "easystats", "epicontacts", "EpiNow2",
# "EpiEstim", "projections", "incidence2", "i2extras", "epitrix", "distcrete",
# "cowplot", "RColorBrewer", "ggnewscale", "DiagrammeR", "gghighlight", "ggrepel",
# "plotly", "gganimate", "sf", "tmap", "OpenStreetMap", "spdep", "rmarkdown",
# "reportfactory", "officer", "flexdashboard", "shiny", "knitr", "flextable",
# "ggtree", "ape", "treeio", "babelquarto", "babeldown")'


- name: Render Book
Expand Down

0 comments on commit 88f683a

Please sign in to comment.