Skip to content

chore: update changed-files.yml #114

chore: update changed-files.yml

chore: update changed-files.yml #114

name: conditional-auto-approve
on:
pull_request:
types:
- opened # default
- synchronize # default
- reopened # default
- ready_for_review # draft -> ready
paths:
- check-change**
- .github/actions/check-change.sh
jobs:
check:
env:
AUTO_APPROVE_FILE_PATH_REGEX: 'check-change/.*/auto-merge/.*.yaml'
AUTO_APPROVE_ALLOWED_REGEX: '(image|replicas)'
PR_COMMENT_CONTENT_TMP_FILE: comment
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Check change and create comment
id: check-change-and-create-comment
env:
SOURCE_BRANCH: ${{ github.head_ref }}
BASE_BRANCH: ${{ github.base_ref }}
working-directory: .github/actions
run: bash ./check-change.sh
- name: Post comment on PR
if: ${{ steps.check-change-and-create-comment.outputs.POST_COMMENT == '1' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.event.pull_request.comments_url }}
working-directory: .github/actions
run: |
echo "{\"body\": \"$(cat "$PR_COMMENT_CONTENT_TMP_FILE")\"}"
status_code=$(curl -o /dev/null -w '%{http_code}\n' -s -X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-d "{\"body\": \"$(cat "$PR_COMMENT_CONTENT_TMP_FILE")\"}" \
"${URL}")
echo "$status_code"
if [[ "$status_code" != 201 ]];then
echo "failed to post with comment:"
exit 1
fi
- name: Get PR number
if: ${{ steps.check-change-and-create-comment.outputs.AUTO_APPROVE == '1' }}
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
echo "pr: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"
- name: Approve Pull Request
if: ${{ steps.check-change-and-create-comment.outputs.AUTO_APPROVE == '1' }}
uses: juliangruber/approve-pull-request-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ env.PR_NUMBER }}
- name: Merge Pull Request
if: ${{ steps.check-change-and-create-comment.outputs.AUTO_APPROVE == '1' }}
uses: juliangruber/merge-pull-request-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ env.PR_NUMBER }}
method: squash