Skip to content

E2E test for pull request #190

E2E test for pull request

E2E test for pull request #190

Workflow file for this run

name: E2E test for pull request
on:
workflow_run:
workflows: ["PR-CI"]
types:
- completed
env:
REPO_NAME: Wuyunfan-BUPT/help
BASE_RUN_URL: https://api.github.com/repos/Wuyunfan-BUPT/help/actions/runs
HEADER: "-H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer ${{ secrets.ACTION_TOKEN }}\" -H \"X-GitHub-Api-Version: 2022-11-28\""
BASE_URL: https://api.github.com/repos/${REPO_NAME}/actions/variables
jobs:
# waitPr:
# runs-on: ubuntu-latest
# steps:
# - name: waiting pr-ci
# run: |
# pr_run_id=${{ github.event.workflow_run.id }}
# echo ${pr_run_id}
# status=`curl -s ${BASE_RUN_URL}/${pr_run_id}/jobs | jq -r '.jobs[] | select(.name == "print test") | .status'`
# echo ${status}
# while [ ${status} != "completed" ]
# do
# echo "waitting..."
# sleep 3
# status=`curl -s ${BASE_RUN_URL}/${pr_run_id}/jobs | jq -r '.jobs[] | select(.name == "print test") | .status'`
# done
# RunIdReturn:
# needs: [waitPr]
# runs-on: ubuntu-latest
# if: >
# github.event.workflow_run.event == 'pull_request' &&
# `curl -s ${BASE_RUN_URL}/${{ github.event.workflow_run.id }}/jobs | jq -r '.jobs[] | select(.name == "print test") | .conclusion'` == 'success'
# steps:
# - name: print workflow_run id
# run: |
# echo `curl -s ${BASE_RUN_URL}/${{ github.event.workflow_run.id }}/jobs | jq -r '.jobs[] | select(.name == "print test") | .conclusion'`
# echo ${{ github.event.workflow_run.id }}
# pr_run_id=${{ github.event.workflow_run.id }}
# echo ${pr_run_id}
# job_id=`curl -s https://api.github.com/repos/Wuyunfan-BUPT/help/actions/runs/${pr_run_id}/jobs | jq -r '.jobs[] | select(.name == "print test") | .id'`
# echo ${job_id}
# echo ${{ github.run_id }}
# runID=${{ github.run_id }}
# data="{\"name\",\"ABC\",\"value\": \"${runID}\"}"
# echo $data
# curl -L -X PATCH -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/Wuyunfan-BUPT/help/actions/variables/VARI_${pr_run_id} -d "{\"name\": \"VARI_${pr_run_id}\",\"value\": \"${runID}\"}"
add-comment:
runs-on: ubuntu-latest
steps:
- name: print issue number
run: |
sleep 5
echo "${{ github.event.issue.number }}"
echo "${{ github.event.pull_request.number }}"
echo `curl -L ${{ env.HEADER }} ${{ env.BASE_URL }}`
number=`curl -L ${{ env.HEADER }} ${{ env.BASE_URL }} | jq -r '.variables[] | select(.name == "VARI_${{ github.event.workflow_run.id }}") | .value'`
echo ${number}
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/Wuyunfan-BUPT/help/issues/${number}/comments -d "{\"body\":\"https://github.com/Wuyunfan-BUPT/help/actions/runs/${{ github.run_id }}\"}"
curl -L -X DELETE ${{ env.HEADER }} ${{ env.BASE_URL }}/VARI_${{ github.event.workflow_run.id }}
# while [ ${number} == "" ]
# do
# echo `curl -L ${{ env.HEADER }} ${{ env.BASE_URL }}`
# echo "number=${number}"
# sleep 3
# number=`curl -L ${{ env.HEADER }} ${{ env.BASE_URL }} | jq -r '.variables[] | select(.name == "VARI_${{ github.event.workflow_run.id }}") | .value'`
# done
# curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/Wuyunfan-BUPT/help/issues/${number}/comments -d "{\"body\":\"https://github.com/Wuyunfan-BUPT/help/actions/runs/${{ github.run_id }}\"}"
# curl -L -X DELETE ${{ env.HEADER }} ${{ env.BASE_URL }}/VARI_${{ github.event.workflow_run.id }}