chore(deps): bump dev-hanz-ops/install-gh-cli-action from 0.2.0 to 0.2.1 #536
This file contains 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: Automatic backport action | |
on: | |
pull_request_target: | |
types: ["labeled", "closed"] | |
jobs: | |
backport: | |
name: Backport PR | |
if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install GH CLI | |
uses: dev-hanz-ops/install-gh-cli-action@v0.2.1 | |
- name: Fetch PR description and update backportrc | |
env: | |
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
REPO: ${{ github.repository }} | |
run: | | |
# Grab raw original PR body, gh CLI uses the default token. | |
BODY_CONTENT="$(gh api "/repos/$REPO/pulls/$PR_NUMBER" | jq -r .body)" | |
# Escape the markdown content so that sed can produce valid JSON. | |
# Remove starting and ending quites and replace new lines with literals. | |
ESCAPED_CONTENT=$(echo "$BODY_CONTENT" | jq -aRs .) | |
ESCAPED_CONTENT="${ESCAPED_CONTENT%\"}" | |
ESCAPED_CONTENT="${ESCAPED_CONTENT#\"}" | |
ESCAPED_CONTENT=$(echo "$ESCAPED_CONTENT" | sed 's/[\/&]/\\&/g') | |
# sourcePullRequest is an actual variable, but the PR description is not provided by the action or the CLI. | |
# Instead we are using it as a substitution target and replacing it with the markdown content. | |
sed -i "s/{{sourcePullRequest}}/$ESCAPED_CONTENT/g" .backportrc.json | |
- name: Backport Action | |
uses: sorenlouv/backport-github-action@v9.5.1 | |
with: | |
github_token: ${{ secrets.GH_ACCESS_TOKEN }} | |
auto_backport_label_prefix: backport-to- | |
- name: Info log | |
if: ${{ success() }} | |
run: cat ~/.backport/backport.info.log | |
- name: Debug log | |
if: ${{ failure() }} | |
run: cat ~/.backport/backport.debug.log | |