Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ntluong95 committed Jun 16, 2024
1 parent 729fb88 commit 2f84106
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/create_pr_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions new_pages/basics.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 2f84106

Please sign in to comment.