|
| 1 | +name: Pull Request Tests |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: ['master'] |
| 5 | + |
| 6 | +env: |
| 7 | + app: Accept:application/vnd.github.v3+json |
| 8 | + base_url: $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs |
| 9 | + AUTH: ${{ secrets.GITHUB_TOKEN }} |
| 10 | + aws_instance_id: ${{ secrets.AWS_INSTANCE_ID }} |
| 11 | + no_instances: 10 |
| 12 | + |
| 13 | +jobs: |
| 14 | + pre: |
| 15 | + name: Preprocess |
| 16 | + runs-on: ubuntu-20.04 |
| 17 | + |
| 18 | + repocheck: |
| 19 | + name: Repo check |
| 20 | + runs-on: ubuntu-20.04 |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Check up-to-dateness and post comment |
| 24 | + run: | |
| 25 | + head_sha=${{ github.event.workflow_run.head_sha }} |
| 26 | + git clone -q ${{ github.event.workflow_run.head_repository.html_url }} . |
| 27 | + git checkout -q $head_sha |
| 28 | + git submodule -q update --init --recursive |
| 29 | + cd ${{ github.workspace }}/tests/ci |
| 30 | + url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY |
| 31 | + pr_number=$(curl -sS -H $app $url/pulls \ |
| 32 | + | jq -r '.[] | select(.head.sha == "'"$head_sha"'") | .number') |
| 33 | + echo "pr_number is $pr_number" |
| 34 | + pr_uid=${{ github.event.workflow_run.head_repository.owner.login }} |
| 35 | + echo "pr_uid is $pr_uid" |
| 36 | + comment="$(./repo_check.sh $pr_uid 2>/dev/null)" |
| 37 | + echo "comment is $comment" |
| 38 | + if [[ -n $comment ]]; then |
| 39 | + curl -sS -X POST -H $app -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 40 | + $url/issues/$pr_number/comments -d '{"body": "'"${comment}"'"}' |
| 41 | + echo -n "failure" >~/repocheck_file |
| 42 | + else |
| 43 | + echo -n "success" >~/repocheck_file |
| 44 | + fi |
| 45 | + - uses: actions/cache@v2 |
| 46 | + with: |
| 47 | + path: ~/repocheck_file |
| 48 | + key: repocheck-${{ github.event.workflow_run.id }} |
0 commit comments