8000 Fix directory workflow script by Panquesito7 · Pull Request #25 · TheAlgorithms/scripts · GitHub
[go: up one dir, main page]

Skip to content

Fix directory workflow script #25

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

Merged
merged 2 commits into from
Jun 14, 2023
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/directory-ignore-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ jobs:
working-directory: .
filetypes: .cpp,.hpp
ignored-directories: ./test
branch-name: directory-update-ignore
1 change: 1 addition & 0 deletions .github/workflows/directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ jobs:
language: scripts
working-directory: ./test
filetypes: .cpp,.hpp
branch-name: directory-update
33 changes: 24 additions & 9 deletions directory_md/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
ignore-folders-children:
description: Folders to ignore, but include children.
required: false
branch-name:
description: The branch that will be used to push changes.
required: false
default: directory-update
runs:
using: composite
steps:
Expand All @@ -35,18 +39,29 @@ runs:
- name: Running the directory builder
shell: bash
run: |
# If branch exists, change to that branch to prevent multiple committing/PR creation.
git checkout ${{ inputs.branch-name }} || true

python build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
- name: Committing changes
- name: Creating a branch
shell: bash
run: |
git branch directory-update
git checkout directory-update
git branch ${{ inputs.branch-name }} || true
git checkout ${{ inputs.branch-name }} || true

git commit -m "docs: update `DIRECTORY.md`" DIRECTORY.md || true
git push origin directory-update:directory-update --force
- name: Creating a pull request
- name: Committing, pushing, and creating a PR
shell: bash
run: |
5C6A if [[ `git status --porcelain` ]]; then
gh pr create --base ${GITHUB_REF##*/} --head directory-update --title 'docs: updating `DIRECTORY.md`' --body 'Updated the `DIRECTORY.md` file (see the diff. for changes).' || true
# `true` is needed in case the PR has been already created to prevent the CI to fail. The changes will already be pushed to the current PR's branch.
if [[ `git status --porcelain` ]];
then

git add DIRECTORY.md

git commit -m "docs: update DIRECTORY.md" || true
git push origin ${{ inputs.branch-name }}:${{ inputs.branch-name }} --force

gh pr create --base ${GITHUB_REF##*/} --head ${{ inputs.branch-name }} --title 'docs: updating `DIRECTORY.md`' --body 'Updated the `DIRECTORY.md` file (see the diff. for changes).' || true
# Using `true` will make sure no errors are displayed even if there's a PR created.
fi
env:
GH_TOKEN: ${{ github.token }}
0