mirror of
https://github.com/ansible/ansible-documentation.git
synced 2026-03-26 13:18:58 +07:00
123 lines
3.6 KiB
YAML
123 lines
3.6 KiB
YAML
---
|
|
name: "Refresh pinned dependencies"
|
|
|
|
"on":
|
|
workflow_call:
|
|
inputs:
|
|
# Commit messae and PR title
|
|
message:
|
|
type: string
|
|
required: true
|
|
# Branch to create PR from
|
|
pr-branch:
|
|
type: string
|
|
required: true
|
|
# Branch to base PR on
|
|
base-branch:
|
|
type: string
|
|
required: true
|
|
# Nox session to call
|
|
nox-args:
|
|
type: string
|
|
required: true
|
|
# Files to commit
|
|
changed-files:
|
|
default: "tests/*.txt"
|
|
type: string
|
|
required: false
|
|
# Reset branch
|
|
reset-branch:
|
|
type: boolean
|
|
default: false
|
|
labels:
|
|
type: string
|
|
default: ""
|
|
jobs:
|
|
refresh:
|
|
runs-on: ubuntu-latest
|
|
environment: github-bot
|
|
steps:
|
|
- name: Generate temp GITHUB_TOKEN
|
|
id: create_token
|
|
uses: tibdex/github-app-token@v2
|
|
with:
|
|
app_id: ${{ secrets.BOT_APP_ID }}
|
|
private_key: ${{ secrets.BOT_APP_KEY }}
|
|
- name: Check out repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: "${{ inputs.base-branch }}"
|
|
token: "${{ steps.create_token.outputs.token }}"
|
|
- name: Fetch required contents of ansible-core
|
|
run: |
|
|
python docs/bin/clone-core.py
|
|
- name: Set up nox
|
|
uses: wntrblm/nox@2024.04.15
|
|
with:
|
|
python-versions: "3.9"
|
|
- name: Set up git committer
|
|
run: |
|
|
hacking/get_bot_user.sh "ansible-documentation-bot" "Ansible Documentation Bot"
|
|
- name: "Use a branch named ${{ inputs.pr-branch }}"
|
|
env:
|
|
base_branch: "${{ inputs.base-branch }}"
|
|
pr_branch: "${{ inputs.pr-branch }}"
|
|
id: branch
|
|
run: |
|
|
set -x
|
|
if git branch -r | grep "origin/${pr_branch}"; then
|
|
echo "branch-exists=true" >> "${GITHUB_OUTPUT}"
|
|
git switch "${pr_branch}"
|
|
${{ inputs.reset-branch && 'git reset --hard' || 'git rebase' }} \
|
|
"${base_branch}"
|
|
else
|
|
echo "branch-exists=false" >> "${GITHUB_OUTPUT}"
|
|
git switch -c "${pr_branch}"
|
|
fi
|
|
- name: "Run nox ${{ inputs.nox-args }}"
|
|
env:
|
|
# Ensure the latest pip version is used
|
|
VIRTUALENV_DOWNLOAD: '1'
|
|
#
|
|
run: |
|
|
nox ${{ inputs.nox-args }}
|
|
- name: Push new dependency versions and create a PR
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
|
|
base_branch: "${{ inputs.base-branch }}"
|
|
pr_branch: "${{ inputs.pr-branch }}"
|
|
message: "${{ inputs.message }}"
|
|
changed_files: "${{ inputs.changed-files }}"
|
|
labels: "${{ inputs.labels }}"
|
|
run: |
|
|
set -x
|
|
git diff || :
|
|
# shellcheck disable=SC2086
|
|
git add ${changed_files}
|
|
# shellcheck disable=SC2086
|
|
if git diff-index --quiet HEAD ${changed_files}; then
|
|
echo "Nothing to do!"
|
|
exit
|
|
fi
|
|
|
|
git commit -m "${message}"
|
|
git push --force origin "${pr_branch}"
|
|
if [ "${{ steps.branch.outputs.branch-exists }}" = "false" ]
|
|
then
|
|
command=(gh pr create
|
|
--base "${base_branch}"
|
|
--title "${message}"
|
|
--body ""
|
|
--label dependency_update
|
|
)
|
|
# Add custom labels to the command.
|
|
old_ifs="$IFS"
|
|
IFS=","
|
|
for label in ${labels}; do
|
|
command+=("--label" "${label}")
|
|
done
|
|
IFS="${old_ifs}"
|
|
fi
|
|
"${command[@]}"
|