This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
feat: добавление правила для защищенной ветки #41
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test on Pull Request | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
checkout: | |
runs-on: front | |
steps: | |
- name: Set up unique workspace | |
id: setup_workspace | |
run: | | |
workspace_path="${{ github.workspace }}/${{ github.event.pull_request.number }}" | |
echo "Using workspace path: $workspace_path" | |
echo "::set-output name=workspace::$workspace_path" | |
- name: Custom Checkout | |
run: | | |
if [ -d ${{ steps.setup_workspace.outputs.workspace }} ]; then | |
echo "Fetching repository changes" | |
cd ${{ steps.setup_workspace.outputs.workspace }} | |
git fetch origin ${{ github.event.pull_request.head.ref }} --depth 1 | |
git reset --hard FETCH_HEAD | |
else | |
echo "Cloning repository" | |
git clone --branch ${{ github.event.pull_request.head.ref }} --depth 1 [email protected]:${{ github.repository }} ${{ steps.setup_workspace.outputs.workspace }} | |
fi | |
setup: | |
runs-on: front | |
needs: checkout | |
steps: | |
- name: Install dependencies | |
run: cd ${{ steps.setup_workspace.outputs.workspace }} && yarn | |
tests: | |
runs-on: front | |
needs: setup | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run tests | |
run: cd ${{ steps.setup_workspace.outputs.workspace }} && yarn test | |
eslint: | |
runs-on: front | |
needs: setup | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run eslint | |
run: cd ${{ steps.setup_workspace.outputs.workspace }} && yarn eslint | |
tslint: | |
runs-on: front | |
needs: setup | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run tslint | |
run: cd ${{ steps.setup_workspace.outputs.workspace }} && yarn tslint | |
prettier: | |
runs-on: front | |
needs: setup | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run prettier | |
run: cd ${{ steps.setup_workspace.outputs.workspace }} && yarn prettier | |
protect: | |
runs-on: front | |
needs: [tests, eslint, tslint, prettier] | |
steps: | |
- name: Protect branch | |
run: echo "Branch is protected" | |
cleanup: | |
runs-on: front | |
needs: protect | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
steps: | |
- name: Clean up workspace | |
run: | | |
workspace_path="${{ github.workspace }}/${{ github.event.pull_request.number }}" | |
echo "Cleaning up workspace: $workspace_path" | |
rm -rf $workspace_path |