Checkout File from Master #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Checkout File from Master | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| file_path: | |
| description: 'Path to the file to checkout from master' | |
| required: true | |
| type: string | |
| default: .github/workflows/sphinxbuild.yml | |
| jobs: | |
| checkout: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target_branch: | |
| - stable20 | |
| - stable21 | |
| - stable22 | |
| - stable23 | |
| - stable24 | |
| - stable25 | |
| - stable26 | |
| - stable27 | |
| - stable28 | |
| - stable29 | |
| - stable30 | |
| - stable31 | |
| - stable32 | |
| - stable33 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 # Fetch full history to access all branches | |
| token: ${{ secrets.COMMAND_BOT_PAT }} | |
| ref: ${{ matrix.target_branch }} | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "nextcloud-command@users.noreply.github.com" | |
| git config --local user.name "nextcloud-command" | |
| - name: Checkout file from master | |
| run: | | |
| echo "Checking out file: ${{ inputs.file_path }} from master branch" | |
| git checkout origin/master -- ${{ inputs.file_path }} | |
| - name: Adjust Python version for older branches | |
| run: | | |
| # Extract version from branch name (e.g., stable32 -> 32) | |
| VERSION=$(echo "${{ matrix.target_branch }}" | sed 's/stable//') | |
| # For branches stable19-stable31, use Python 3.10 instead of 3.13 | |
| if [ "$VERSION" -le 31 ]; then | |
| if grep -q "3.13" "${{ inputs.file_path }}"; then | |
| sed -i 's/3\.13/3.10/g' "${{ inputs.file_path }}" | |
| echo "Updated Python version to 3.10 for stable$VERSION" | |
| fi | |
| fi | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| with: | |
| token: ${{ secrets.COMMAND_BOT_WORKFLOWS }} | |
| commit-message: 'chore: update ${{ inputs.file_path }} from master branch' | |
| committer: GitHub <noreply@github.com> | |
| author: nextcloud-command <nextcloud-command@users.noreply.github.com> | |
| signoff: true | |
| branch: 'workflow/update-${{ inputs.file_path }}-${{ matrix.target_branch }}' | |
| base: ${{ matrix.target_branch }} | |
| title: '[${{ matrix.target_branch }}] chore: update `${{ inputs.file_path }}` from the master branch' | |
| body: 'Automated update of `${{ inputs.file_path }}` from the master branch' | |
| labels: github_actions, 3. to review | |
| assignees: ${{ github.actor }} |