diff --git a/.github/workflows/generate_prs.yml b/.github/workflows/generate_prs.yml index a9384865..9dcb745a 100644 --- a/.github/workflows/generate_prs.yml +++ b/.github/workflows/generate_prs.yml @@ -9,6 +9,8 @@ on: message: description: "Message to include in the generated commits:" required: true + custom-pr-title: + description: "Optionally a custom PR title. If unset, default will be used" dry-run: description: "Dry Run (PRs are not generated)" type: boolean @@ -155,12 +157,18 @@ jobs: # Generate PRs - name: Run playbook if: ${{ !inputs.dry-run }} + env: + CUSTOM_PR_TITLE: ${{ inputs.custom-pr-title }} + GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }} run: | # Funnel via JSON to ensure that values are escaped properly - echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json + # Check if custom PR title is set. If so, insert it into the extra vars + if [ -n "$CUSTOM_PR_TITLE" ]; then + echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, custom_pr_title: $ENV.CUSTOM_PR_TITLE, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json + else + echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json + fi ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json" - env: - GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }} # Do Not Generate PRs - name: Run playbook (dry-run) diff --git a/playbook/group_vars/all/vars b/playbook/group_vars/all/vars index c4b96282..a697eb0d 100644 --- a/playbook/group_vars/all/vars +++ b/playbook/group_vars/all/vars @@ -19,7 +19,7 @@ commit_message: | Reference-to: stackabletech/operator-templating@{{ commit_short_hash }} ({{ reason }}) # Title and body of created PRs -pr_title: "chore: Update templated files ({{ commit_short_hash }})" +pr_title: "{{ custom_pr_title | default('chore: Update templated files (' + commit_short_hash + ')') }}" pr_body: | > [!NOTE] > _Autogenerated PR to update templated files since the last template run up to stackabletech/operator-templating@{{ commit_hash }}._