@@ -18,6 +18,10 @@ inputs:
1818 ignore-folders-children :
1919 description : Folders to ignore, but include children.
2020 required : false
21+ branch-name :
22+ description : The branch that will be used to push changes.
23+ required : false
24+ default : directory-update
2125runs :
2226 using : composite
2327 steps :
@@ -35,18 +39,29 @@ runs:
3539 - name : Running the directory builder
3640 shell : bash
3741 run : |
42+ # If branch exists, change to that branch to prevent multiple committing/PR creation.
43+ git checkout ${{ inputs.branch-name }} || true
44+
3845 python build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
39- - name : Committing changes
46+ - name : Creating a branch
4047 shell : bash
4148 run : |
42- git branch directory-update
43- git checkout directory-update
49+ git branch ${{ inputs.branch-name }} || true
50+ git checkout ${{ inputs.branch-name }} || true
4451
45- git commit -m "docs: update `DIRECTORY.md`" DIRECTORY.md || true
46- git push origin directory-update:directory-update --force
47- - name : Creating a pull request
52+ - name : Committing, pushing, and creating a PR
4853 shell : bash
4954 run : |
50- if [[ `git status --porcelain` ]]; then
51- 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
52- # `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.
55+ if [[ `git status --porcelain` ]];
56+ then
57+
58+ git add DIRECTORY.md
59+
60+ git commit -m "docs: update DIRECTORY.md" || true
61+ git push origin ${{ inputs.branch-name }}:${{ inputs.branch-name }} --force
62+
63+ 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
64+ # Using `true` will make sure no errors are displayed even if there's a PR created.
65+ fi
66+ env :
67+ GH_TOKEN : ${{ github.token }}
0 commit comments