Skip to content

Update nonAPI.txt

Update nonAPI.txt #90

Workflow file for this run

name: Update nonAPI.txt
on:
# Run this weekly
schedule:
- cron: '42 12 * * 1'
# This can also manually run
workflow_dispatch: {}
jobs:
update_nonAPI_txt:
runs-on: ${{ matrix.config.os }}
name: Update nonAPI.txt on ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest}
- {os: macOS-latest}
- {os: ubuntu-latest}
steps:
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: 'devel'
- name: Update nonAPI.txt
run: |
# Update the non-API list first
Rscript -e 'cat(tools:::nonAPI, sep = "\n")' | tr -d '\r' | sort -u | tee ./nonAPI.txt
shell: bash
- name: Upload nonAPI.txt
uses: actions/upload-artifact@v4
with:
name: nonAPI-${{ matrix.config.os }}
path: nonAPI.txt
commit_nonAPI_txt:
needs: update_nonAPI_txt
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Switch branch
run: |
# 1) If there's already update_nonAPI_txt branch, checkout it.
# 2) If update_nonAPI_txt branch is not created, create it from the default branch.
if git ls-remote --exit-code --heads origin update_nonAPI_txt 2>&1 >/dev/null; then
git fetch origin --no-tags --prune --depth=1 update_nonAPI_txt
git checkout update_nonAPI_txt
else
git switch -c update_nonAPI_txt
fi
- name: Commit and create a pull request
run: |
# Merge all nonAPI.txt
cat nonAPI-*/nonAPI.txt | tr -d '\r' | sort -u | tee nonAPI.txt
# detect changes (the code is derived from https://stackoverflow.com/a/3879077)
git add nonAPI.txt
git update-index --refresh
if ! git diff-index --quiet HEAD -- nonAPI.txt; then
# commit
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -m "nonAPI.txt [skip ci]"
# push to the origin
git push origin update_nonAPI_txt
# create the pull request
gh pr create --title "Update nonAPI.txt" --body "Please review the diff and run /bindings command manually."
else
echo "No changes"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}