|
| 1 | +name: commit to pull request |
| 2 | +description: | |
| 3 | + checkout pull request, run provided script and push back changes |
| 4 | + The action expects a python script to be executed |
| 5 | +
|
| 6 | +inputs: |
| 7 | + python_libs: |
| 8 | + description: | |
| 9 | + Required libraries to execute the python script |
| 10 | + for example 'pyyaml urllib' |
| 11 | + required: false |
| 12 | + default: "" |
| 13 | + python_executable_url: |
| 14 | + description: URL of the script to download to update the repository |
| 15 | + required: true |
| 16 | + commit_message: |
| 17 | + description: commit message |
| 18 | + required: false |
| 19 | + default: Apply automatic changes |
| 20 | + file_pattern: |
| 21 | + description: File pattern used for `git add`. For example `src/*.js` |
| 22 | + required: false |
| 23 | + default: "." |
| 24 | +outputs: |
| 25 | + changes_detected: |
| 26 | + description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected. |
| 27 | + value: ${{ steps.commit.outputs.changes_detected }} |
| 28 | + commit_hash: |
| 29 | + description: Full hash of the created commit. Only present if the "changes_detected" output is "true". |
| 30 | + value: ${{ steps.commit.outputs.commit_hash }} |
| 31 | + |
| 32 | +runs: |
| 33 | + using: composite |
| 34 | + steps: |
| 35 | + - name: checkout fork repository |
| 36 | + uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 39 | + ref: ${{ github.head_ref }} |
| 40 | + |
| 41 | + - name: Set up Python |
| 42 | + uses: actions/setup-python@v4 |
| 43 | + with: |
| 44 | + python-version: "3.9" |
| 45 | + |
| 46 | + - name: Install required python libraries |
| 47 | + run: pip install -U ${{ inputs.python_libs }} |
| 48 | + shell: bash |
| 49 | + if: inputs.python_libs != '' |
| 50 | + |
| 51 | + - name: Download python script |
| 52 | + run: >- |
| 53 | + curl -o /tmp/update_repository.py ${{ inputs.python_executable_url }} |
| 54 | + shell: bash |
| 55 | + |
| 56 | + - name: Execute python script |
| 57 | + run: >- |
| 58 | + python /tmp/update_repository.py |
| 59 | + shell: bash |
| 60 | + |
| 61 | + - name: commit and push changes |
| 62 | + id: commit |
| 63 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 64 | + with: |
| 65 | + commit_message: ${{ inputs.commit_message }} |
| 66 | + file_pattern: ${{ inputs.file_pattern }} |
0 commit comments