Skip to content

hw git2 olegfateev13 #207

hw git2 olegfateev13

hw git2 olegfateev13 #207

Workflow file for this run

name: automerge
on:
pull_request_target:
types:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked
paths:
- '*.sh'
# pull_request_review:
# types:
# - submitted
check_suite:
types:
- completed
status: {}
jobs:
automerge:
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
- name: check branch
id: checkbranch
continue-on-error: false
run: |
echo Github nick ${{ github.event.pull_request.user.login }}
echo Branch ${{ github.event.pull_request.head.ref }}
if [ "${{ github.event.pull_request.head.ref }}" != "${{ github.event.pull_request.user.login }}" ]
then
echo "Branch name is not the same as github nick"
exit 1
fi
- name: check title
id: checktitle
continue-on-error: false
run: |
echo Title ${{ github.event.pull_request.title }}
if [ "${{ github.event.pull_request.title }}" != "hw git2 ${{ github.event.pull_request.user.login }}" ]
then
echo "PR title is not hw git2 your_github_nick"
exit 1
fi
- name: check number of commits
id: checkcommits
continue-on-error: false
run: |
echo Commits ${{ github.event.pull_request.commits }}
if [ "${{ github.event.pull_request.commits }}" -ne 1 ]
then
echo "Number of commits in this PR is not 1"
exit 1
fi
- name: check number of changed files
id: checkchangedfiles
continue-on-error: false
run: |
echo Changed files ${{ github.event.pull_request.changed_files }}
if [ "${{ github.event.pull_request.changed_files }}" -ne 1 ]
then
echo "Number of changed files in this PR is not 1"
exit 1
fi
# - name: get changed files
# id: getchfile
# continue-on-error: true
# run: |
# echo BASE SHA ${{ github.event.pull_request.base.sha }}
# echo HEAD SHA ${{ github.event.pull_request.head.sha }}
# echo SHA ${{ github.sha }}
# echo "::set-output name=files::$(git diff --no-commit-id --name-only -r ${{ github.event.pull_request.base.sha }} | xargs)"
# echo CHANGED FILES ${{ steps.getchfile.outputs.files }}
#could try to decode what's encoded like
#"${description//'%'/'%25'}"
#"${description//$'\n'/'%0A'}"
#description="${description//$'\r'/'%0D'}"
- name: run programm
id: runprog
continue-on-error: false
run: |
echo Running ./${{ github.event.pull_request.user.login }}.sh
out=$(./${{ github.event.pull_request.user.login }}.sh)
if [ $? -ne 0 ]; then
echo Could not run ./"${{ github.event.pull_request.user.login }}.sh"
exit 1
fi
echo Output:${out}
if [ "$out" != "Hello pull-request" ]; then
echo Incorrect output $out
exit 1
fi
- name: merge pull request
run: |
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
${{ github.event.pull_request.url }}/merge \
-d '{"commit_title":"automerging pr ${{github.event.pull_request.number }} for ${{ github.event.pull_request.user.login }}" }'