Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various GH workflow improvements #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .github/workflows/directory_workflow.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/directory_writer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Directory writer
on:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 0 * * *'
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What extra space? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here
image

workflow_dispatch:
jobs:
build:
if: github.repository == 'TheAlgorithms/R' # We only need this to run in our repository.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build directory
uses: TheAlgorithms/scripts/directory_md@main
with:
language: R
working-directory: .
filetypes: .r
ignored-directories: .github/,documentation/
33 changes: 20 additions & 13 deletions .github/workflows/documentation_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
name: Documentation
on: [push, pull_request]

jobs:
MakeDocs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup R
uses: r-lib/actions/setup-r@v2-branch
with:
r-version: '4.1.0'
- name: Create Documentation directory
run: |
echo "Creating 'Documentation'"
echo "Creating documentation directory"
mkdir -p documentation
- name: Install knitr dependency
run: |
echo "Installing R package dependencies. Scripts might have additional dependencies installed."
Rscript -e 'if (!require(knitr)) install.packages("knitr")'
- name: Documentation compilation
run: 'Rscript .github/scripts/doc_builder.r'
- name: Commit Documentation
- name: Setup Git
run: |
echo "Setting up Git"
git config --global user.name github-actions[bot]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could get username and email from an environment variable? GITHUB_ACTOR or a similar one

git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Creating a branch
run: |
git diff-index --quiet HEAD && exit
echo "Setting up Git to push changes."
git config --global user.name 'autoprettier'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
echo "Staging documentation"
git add documentation/ # This is the only directory that has changes and should be staged
git commit -m "Update documentation" || true
git push || true
git checkout -b docs_update-${{ github.sha }}
- name: Commit and push changes
run: |
if [[ `git status --porcelain` ]];
then
echo "Staging and committing documentation changes"
git add documentation/
git commit -m "Update documentation" || true
git push origin docs_update-${{ github.sha }}:docs_update-${{ github.sha }}

gh pr create --base ${GITHUB_REF##*/} --head docs_update-${{ github.sha }} --title '' --body 'Updated the documentation files (see the diff. for changes).' || true
fi
14 changes: 14 additions & 0 deletions .github/workflows/filename_formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Filename formatter
on: [push, workflow_dispatch]
jobs:
formatter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Filename Formatter
uses: TheAlgorithms/scripts/formatter@main
with:
filetypes: .r
ignore-files: documentation/,.github/
Loading