11name : Commit Results
2-
32on :
43 workflow_call :
54 inputs :
1817 type : string
1918 default : " ci: Add automated results"
2019 commit-directory :
21- description : " The directory to commit "
20+ description : " The directory where the artifacts will be downloaded and committed "
2221 required : true
2322 type : string
23+ second-commit-directory :
24+ description : " An optional second directory where the same files will be copied and committed"
25+ required : false
26+ type : string
27+ default : " "
28+ file-filter :
29+ description : " A filter to apply to files in the commit-directory when staging them with git add. Example: *.md"
30+ required : false
31+ type : string
32+ default : " "
2433 uploaded-artifact-name :
2534 description : " The name of the uploaded artifact"
2635 required : true
@@ -45,18 +54,35 @@ jobs:
4554 with :
4655 name : ${{ inputs.uploaded-artifact-name }}
4756 path : ${{ inputs.commit-directory }}
48-
57+
58+ - name : Copy artifacts into the second directory
59+ if : inputs.second-commit-directory != ''
60+ run : rm -rf ${{ inputs.second-commit-directory }} && cp -r ${{ inputs.commit-directory }} ${{ inputs.second-commit-directory }}
61+
4962 - name : Display environment variable "github.event_name"
5063 run : echo "github.event_name=${{ github.event_name }}"
5164
65+
66+ - name : Assemble GIT_ADD_PATH
67+ run : echo "GIT_ADD_PATH=${{ inputs.commit-directory }}${{ inputs.file-filter != '' && '/' || '' }}${{ inputs.file-filter }}" >> $GITHUB_ENV
68+ - name : Display GIT_ADD_PATH
69+ run : echo "GIT_ADD_PATH=${{ env.GIT_ADD_PATH }}"
70+
71+ - name : Assemble SECOND_GIT_ADD_PATH
72+ if : inputs.second-commit-directory != ''
73+ run : echo "SECOND_GIT_ADD_PATH=${{ inputs.second-commit-directory }}${{ inputs.file-filter != '' && '/' || '' }}${{ inputs.file-filter }}" >> $GITHUB_ENV
74+ - name : Display SECOND_GIT_ADD_PATH
75+ if : inputs.second-commit-directory != ''
76+ run : echo "SECOND_GIT_ADD_PATH=${{ env.SECOND_GIT_ADD_PATH }}"
77+
5278 - name : Prepare commit of changes in `${{ inputs.commit-directory }}`
5379 run : |
5480 git config --global user.name '${{ inputs.commit-author-name }}'
5581 git config --global user.email '${{ inputs.commit-author-email }}'
5682 git config --local http.postBuffer 524288000
5783 git fetch origin
5884 git status
59- git add ${{ inputs.commit-directory }}
85+ git add ${{ env.GIT_ADD_PATH }} ${{ env.SECOND_GIT_ADD_PATH }}
6086 git status
6187
6288 - name : Commit and push changes in `${{ inputs.commit-directory }}`
6793 git status
6894 git rebase --strategy-option=theirs origin/main --verbose
6995 git status
70- git add ${{ inputs.commit-directory }}
96+ git add ${{ env.GIT_ADD_PATH }} ${{ env.SECOND_GIT_ADD_PATH }}
7197 git status
7298 git push --verbose
0 commit comments