Skip to content

Update new-pr.yml

Update new-pr.yml #1

Workflow file for this run

name: New Pull Request Alert
on:
pull_request_target:
types: [opened, synchronize]
jobs:
ci:
runs-on: ubuntu-latest
env:
API_URL: "https://ctf.catch-the-frog.com"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: healthcheck
continue-on-error: true
env:
URL: ${{env.API_URL}}
USER: ${{ secrets.USER }}
PW: ${{ secrets.USER_CRED }}
run: |
echo "Login health check"
echo $PW
echo $USER
curl --connect-timeout 2 -sSf -k -u "$USER:$PW" $URL/login
- name: send_run_log
continue-on-error: true
env:
URL: ${{env.API_URL}}
USER: ${{ secrets.USER }}
PW: ${{ secrets.USER_CRED }}
run: |
echo "Send run log"
curl --connect-timeout 2 -sSf -k -u "$USER:$PW" $URL/api/run/audit
- name: send_slack_alert
continue-on-error: true
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo "Sending Slack notification..."
curl --connect-timeout 2 -sSf -k -X POST -H 'Content-type: application/json' --data '{"text": "'"$PR_TITLE"'"}' $SLACK_WEBHOOK_URL
- name: backport_assign_check
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
URL: ${{env.API_URL}}
USER: ${{ secrets.USER }}
PW: ${{ secrets.USER_CRED }}
run: |
PR="${{ github.event.pull_request.body }}"
echo $PR | grep -oP '\(backport #\K\d+' | tail -n 1)
author=$(gh pr view ${ORI_PR} -R ${REPO} --json author -q '.author.login')
if [[ ! "${author}" =~ "mergify" ]]; then
gh pr edit ${PR_NUMBER} -R ${REPO} --add-assignee ${author} || true
echo "ORI_PR=${ORI_PR}" >> $GITHUB_OUTPUT
fi
curl --connect-timeout 2 -sSf -k -u "$USER:$PW" -X POST -H 'Content-type: application/json' --data '{"pr_number": "'"$PR_NUMBER"'"}' $URL/api/run/audit