@@ -18,6 +18,10 @@ inputs:
18
18
ignore-folders-children :
19
19
description : Folders to ignore, but include children.
20
20
required : false
21
+ branch-name :
22
+ description : The branch that will be used to push changes.
23
+ required : false
24
+ default : directory-update
21
25
runs :
22
26
using : composite
23
27
steps :
@@ -35,18 +39,29 @@ runs:
35
39
- name : Running the directory builder
36
40
shell : bash
37
41
run : |
42
+ # If branch exists, change to that branch to prevent multiple committing/PR creation.
43
+ git checkout ${{ inputs.branch-name }} || true
44
+
38
45
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
40
47
shell : bash
41
48
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
44
51
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
48
53
shell : bash
49
54
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