Skip to content

update build_book workflow file #80

update build_book workflow file

update build_book workflow file #80

Workflow file for this run

name: Build Book with Babel Quarto
on:
pull_request:
branches:
- crowdin_integration
push:
branches:
- crowdin_integration
workflow_dispatch:
env:
NEW_BRANCH: build_book-
jobs:
build_book:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
env:
CONFIG_PATH: ./config.json
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: true
- name: Read CONFIG file
id: read_config
run: |
JSON_FILE="$CONFIG_PATH"
JSON_CONTENT=$(cat "$JSON_FILE")
# JSON_CONTENT="${JSON_CONTENT//'%'/'%25'}"
# JSON_CONTENT="${JSON_CONTENT//$'\n'/'%0A'}"
# JSON_CONTENT="${JSON_CONTENT//$'\r'/'%0D'}"
echo "LANGUAGES=${JSON_CONTENT.languages}" >> $GITHUB_ENV
echo "::set-output name=JSON_CONTENT::$JSON_CONTENT";
JSON_FILE="$CONFIG_PATH"
# if [ -f "JSON_FILE" ]; then
# echo "CONFIG_PATH=$CONFIG_PATH"
# JSON_CONTENT=$(cat "$JSON_FILE")
# # JSON_CONTENT="${JSON_CONTENT//'%'/'%25'}"
# # JSON_CONTENT="${JSON_CONTENT//$'\n'/'%0A'}"
# # JSON_CONTENT="${JSON_CONTENT//$'\r'/'%0D'}"
# echo "LANGUAGES=${JSON_CONTENT.languages}" >> $GITHUB_ENV
# echo "::set-output name=JSON_CONTENT::$JSON_CONTENT";
# else
# echo "JSON file not found at $CONFIG_PATH"
# exit 1
# fi
- name: Use CONFIG variables from file
run: |
echo "${{env.LANGUAGES}}"
echo "${{ steps.read_config.outputs.JSON_CONTENT }}"
echo "${{fromJson(steps.set_var.outputs.JSON_CONTENT).languages}}"
- name: Set New Branch Name
id: set_branch
run: echo "NEW_BRANCH=${NEW_BRANCH}$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_ENV
- name: Setup R
run: |
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-core
sudo apt-get install libssl-dev libcurl4-openssl-dev libxml2-dev
- name: Create writable directory
run: |
mkdir ./my_R_library
chmod u+w ./my_R_library
- name: Setup quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Install PAK
run: Rscript -e "install.packages('pak', lib='./my_R_library')"
- name: Install Babel quarto
run: Rscript -e ".libPaths(c('./my_R_library', .libPaths())); library(pak); pak::pak('ropensci-review-tools/babelquarto', lib='./my_R_library')"
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm install
- name: Prepare crowdin translations
run: npm run fix:crowdin_files languages=en,ar
- name: Build book
run: |
Rscript -e ".libPaths(c('./my_R_library', .libPaths())); library(babelquarto); project_dir <- 'docs'; babelquarto::render_book(project_path = project_dir)"
- name: Fix built book
run: |
tree docs
npm run fix:all languages=en,ar
- name: Commit changes
run: |
git config --global user.email "molunorichie@gmail.com"
git config --global user.name "Richie"
git checkout -b $NEW_BRANCH
git status
git add .
git commit -m "Build book with babelquarto"
git push origin $NEW_BRANCH
- name: Create Pull Request
id: create_pr
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ env.NEW_BRANCH }}
destination_branch: build_crowdin_integration
pr_title: New book build with babelquarto
pr_body: |
:crown: *An automated PR*
Automated PR build book with babel-quarto
_Created by [repo-sync/pull-request](https://github.com/repo-sync/pull-request)_
pr_reviewer: "@RealRichi3"
pr_assignee: "RealRichi3"
pr_label: "auto-pr"
pr_draft: false
pr_allow_empty: true
token: ${{ secrets.PAT_TOKEN }}
- name: Pull request number
run: echo "Pull Request Number - ${{ steps.create_pr.outputs.pull_request_number }}"
id: pr_number