From 2f84106e3a46326dacdcb2ef209aebbdfc6a2251 Mon Sep 17 00:00:00 2001 From: Luong Nguyen Thanh Date: Sun, 16 Jun 2024 17:01:49 +0200 Subject: [PATCH] first commit --- .github/workflows/create_pr_on_pr.yml | 24 +++++++++++++++++------- new_pages/basics.qmd | 5 +++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/create_pr_on_pr.yml b/.github/workflows/create_pr_on_pr.yml index 0fbd9013..41878f14 100644 --- a/.github/workflows/create_pr_on_pr.yml +++ b/.github/workflows/create_pr_on_pr.yml @@ -29,30 +29,40 @@ jobs: LANGS=("fr" "es" "vn" "jp" "tr" "pt" "ru") EN_BRANCH="${{ github.ref }}" VERSION_SUFFIX="${EN_BRANCH#refs/heads/handbook_}" + + # Fetch the latest changes from the remote repository + git fetch origin for lang in "${LANGS[@]}"; do TRANSLATION_BRANCH="handbook_${VERSION_SUFFIX/_en/_$lang}" + # Check if the translation branch exists - if git rev-parse --verify --quiet "${TRANSLATION_BRANCH}"; then + if git ls-remote --exit-code --heads origin "${TRANSLATION_BRANCH}"; then + echo "Branch ${TRANSLATION_BRANCH} exists. Checking out and rebasing with ${EN_BRANCH}" git checkout "${TRANSLATION_BRANCH}" - git pull origin "${EN_BRANCH}" --rebase + git pull origin "${TRANSLATION_BRANCH}" + git rebase "origin/${EN_BRANCH#refs/heads/}" else - git checkout -b "${TRANSLATION_BRANCH}" + echo "Branch ${TRANSLATION_BRANCH} does not exist. Creating new branch from ${EN_BRANCH}." + git checkout -b "${TRANSLATION_BRANCH}" "origin/${EN_BRANCH#refs/heads/}" git pull origin "${EN_BRANCH}" fi - git push origin "${TRANSLATION_BRANCH}" + + # Force push the changes to the remote repository + git push origin "${TRANSLATION_BRANCH}" --force # Check if a PR already exists for this branch PR_EXISTS=$(gh pr list --head "${TRANSLATION_BRANCH}" --state open --json number --jq length) if [ "$PR_EXISTS" -eq 0 ]; then + echo "Creating new PR for ${TRANSLATION_BRANCH}" PR_URL=$(gh pr create --base main --head "$TRANSLATION_BRANCH" --title "Handbook ${VERSION_SUFFIX/_en/} $lang" --body "Automated pull request for $lang handbook version ${VERSION_SUFFIX/_en/}") PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') else # Get the PR number for the translation branch - PR_NUMBER=$(gh pr list --base main --json number --jq ".[] | select(.headRefName == \"$TRANSLATION_BRANCH\") | .number") - + echo "PR already exists for ${TRANSLATION_BRANCH}" + PR_NUMBER=$(gh pr list --head "${TRANSLATION_BRANCH}" --state open --json number --jq ".[0].number") fi echo "Pull Request Number: $PR_NUMBER" @@ -71,7 +81,7 @@ jobs: # Mention a user in the PR description if [ "$lang" == "es" ]; then - checkboxes="$checkboxes\n\n@robcrystalornelas, please review." + checkboxes="$checkboxes @robcrystalornelas, please review." fi gh api repos/${{ github.repository }}/issues/$PR_NUMBER --method PATCH --field body="$checkboxes" diff --git a/new_pages/basics.qmd b/new_pages/basics.qmd index ca13857f..c8250945 100644 --- a/new_pages/basics.qmd +++ b/new_pages/basics.qmd @@ -306,6 +306,11 @@ This basics section on functions explains: sqrt(49) ``` +Another example of function +```{r basics_function_round} +round(3.14159, 2) +``` + The object provided to a function also can be a column in a dataset (see the [Objects](#objects) section for detail on all the kinds of objects). Because R can store multiple datasets, you will need to specify both the dataset and the column. One way to do this is using the `$` notation to link the name of the dataset and the name of the column (`dataset$column`). In the example below, the function `summary()` is applied to the numeric column `age` in the dataset `linelist`, and the output is a summary of the column's numeric and missing values. ```{r basics_functions_summary}