|
| 1 | +--- |
| 2 | +name: Ansible porting guide creation |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + ansible-build-data-branch: |
| 7 | + description: >- |
| 8 | + Release Branch name from the Ansible Build data PR. |
| 9 | + (e.g. `refs/pull/1/merge`) |
| 10 | + required: true |
| 11 | + ansible-version: |
| 12 | + description: >- |
| 13 | + Exact release version. For example, 12.1.0 |
| 14 | + required: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + upload-porting-guide: |
| 18 | + name: Extract the porting guide |
| 19 | + runs-on: ubuntu-latest |
| 20 | + env: |
| 21 | + GIT_BRANCH: "release/porting-guide-${{ inputs.ansible-version }}" |
| 22 | + ANSIBLE_VERSION_FULL: ${{ inputs.ansible-version }} |
| 23 | + CI_COMMIT_MESSAGE: >- |
| 24 | + Add the Ansible community ${{ inputs.ansible-version }} porting guide |
| 25 | +
|
| 26 | + steps: |
| 27 | + - name: Extract the major version |
| 28 | + run: echo "ANSIBLE_VERSION_MAJOR=${ANSIBLE_VERSION_FULL%%.*}" >> "${GITHUB_ENV}" |
| 29 | + shell: bash --noprofile --norc -O extglob -eEuo pipefail {0} |
| 30 | + |
| 31 | + - name: Check out this repo src |
| 32 | + uses: actions/checkout@v4 |
| 33 | + - name: Check out ansible-build-data |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + repository: ansible-community/ansible-build-data |
| 37 | + ref: ${{ inputs.ansible-build-data-branch }} |
| 38 | + path: ansible-build-data |
| 39 | + |
| 40 | + - name: Copy the RST file to the correct path |
| 41 | + run: >- |
| 42 | + cp -v |
| 43 | + "ansible-build-data/${ANSIBLE_VERSION_MAJOR}/porting_guide_${ANSIBLE_VERSION_MAJOR}.rst" |
| 44 | + docs/docsite/rst/porting_guides/ |
| 45 | +
|
| 46 | + - name: Set up git |
| 47 | + run: | |
| 48 | + git switch --create "${GIT_BRANCH}" |
| 49 | + ACTOR_NAME="$(curl -s https://api.github.com/users/"${GITHUB_ACTOR}" | jq --raw-output '.name // .login')" |
| 50 | + git config --global user.name "${ACTOR_NAME}" |
| 51 | + git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" |
| 52 | +
|
| 53 | + - name: Add the porting guide |
| 54 | + run: git add docs/docsite/rst/porting_guides/"porting_guide_${ANSIBLE_VERSION_MAJOR}.rst" |
| 55 | + |
| 56 | + - name: Commit the porting guide |
| 57 | + run: >- |
| 58 | + git diff-index --quiet HEAD || |
| 59 | + git commit -m "${CI_COMMIT_MESSAGE}" |
| 60 | +
|
| 61 | + - name: Push to the repo |
| 62 | + run: git push origin "${GIT_BRANCH}" |
| 63 | + |
| 64 | + - name: Create the porting guide PR as draft |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ github.token }} |
| 67 | + PR_BODY_MESSAGE: |- |
| 68 | + ##### SUMMARY |
| 69 | +
|
| 70 | + This is a draft PR. Please mark the PR as ready for review to trigger PR checks. |
| 71 | +
|
| 72 | + ##### ISSUE TYPE |
| 73 | +
|
| 74 | + - Docs Pull Request |
| 75 | +
|
| 76 | + ##### COMPONENT NAME |
| 77 | +
|
| 78 | + docs/docsite/rst/porting_guides/porting_guide_${{ env.ANSIBLE_VERSION_MAJOR }}.rst |
| 79 | + run: >- |
| 80 | + gh pr create |
| 81 | + --draft |
| 82 | + --base devel |
| 83 | + --head "${GIT_BRANCH}" |
| 84 | + --title "${CI_COMMIT_MESSAGE}" |
| 85 | + --body "${PR_BODY_MESSAGE}" |
0 commit comments