Skip to content

Commit

Permalink
add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntluong95 committed Jun 16, 2024
1 parent 2f84106 commit f2a0496
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
41 changes: 24 additions & 17 deletions .github/workflows/create_pr_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
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}"
Expand All @@ -42,37 +40,45 @@ jobs:
git checkout "${TRANSLATION_BRANCH}"
git pull origin "${TRANSLATION_BRANCH}"
git rebase "origin/${EN_BRANCH#refs/heads/}"
else
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}"
git checkout -b "${TRANSLATION_BRANCH}"
git pull origin "${EN_BRANCH#refs/heads/}"
fi
# Force push the changes to the remote repository
git push origin "${TRANSLATION_BRANCH}" --force
# Get the date of the latest commit on the translation branch
latest_commit_date=$(git show -s --format=%ci ${TRANSLATION_BRANCH})
commits=$(gh api repos/${{ github.repository }}/commits --paginate --jq ".[] | select(.commit.author.date > \"$latest_commit_date\") | .sha")
# commits=$(git log origin/"${EN_BRANCH#refs/heads/}" --since="$latest_commit_date" --pretty=format:"%H")
echo "Commits on the English branch that were made after the latest commit on the translation branch: $commits at $latest_commit_date"
# Check if there are new commits
if [ -z "$commits" ]; then
echo "No new commits to include in PR for ${TRANSLATION_BRANCH}"
continue
fi
# 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_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_URL=$(gh pr create --base "${EN_BRANCH#refs/heads/}" --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
# Get the PR number for the translation branch
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"
# Get the date of the latest commit on the translation branch
latest_commit_date=$(git show -s --format=%ci ${TRANSLATION_BRANCH})
# Get the commits on the English branch that were made after the latest commit on the translation branch
commits=$(gh api repos/${{ github.repository }}/commits --paginate --jq ".[] | select(.commit.author.date > \"$latest_commit_date\") | .sha")
# Add new commits as checkboxes to the PR description
checkboxes=""
for commit in $commits; do
Expand All @@ -85,6 +91,7 @@ jobs:
fi
gh api repos/${{ github.repository }}/issues/$PR_NUMBER --method PATCH --field body="$checkboxes"
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ knitr::include_graphics(here::here("images", "Epi R Handbook banner beige 1500x5

**Are you just starting with R?** Try our [**free interactive tutorials**](https://www.appliedepi.org/tutorial/) or synchronous, virtual [**intro course**](https://www.appliedepi.org/live/) used by US CDC, WHO, and 400+ other health agencies and Field Epi Training Programs worldwide.

**Who is this for?** Epidemiologists, public health professionals, and students who want to learn R for data analysis, visualization, and reporting.

**Languages:** [French (Français)](https://epirhandbook.com/fr), [Spanish (Español)](https://epirhandbook.com/es/), [Vietnamese (Tiếng Việt)](https://epirhandbook.com/vn/), [Japanese (日本)](https://epirhandbook.com/jp/), [Turkish (Türkçe)](https://epirhandbook.com/tr/), [Portuguese (Português)](https://epirhandbook.com/pt), [Russian (Русский)](https://epirhandbook.com/ru)

<!-- * Use practical epi examples - cleaning case linelists, making transmission chains and epidemic curves, automated reports and dashboards, modeling incidence and making projections, demographic pyramids and rate standardization, record matching, outbreak detection, survey analysis, survival analysis, GIS basics, contact tracing, phylogenetic trees... -->
Expand Down

0 comments on commit f2a0496

Please sign in to comment.