Skip to content

Commit

Permalink
Feature ETO-323: Add Git Police to workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
facumoyanosmf committed May 22, 2024
1 parent 779d770 commit c663441
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/auto-reviewer.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Auto Reviewer

on:
pull_request:
types: [opened, reopened, synchronize]
workflow_run:
workflows: [Git Police]
types: [completed]

jobs:
make-review:
if: github.head_ref != 'develop'
if: ${{ github.event.workflow_run.conclusion == 'success' }} && github.head_ref != 'develop'
runs-on: ubuntu-latest
env:
PULL_REQUEST: ${{ github.event.pull_request.number }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Sonar Build
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_run:
workflows: [Git Police]
types: [completed]
push:
branches:
- main
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/git-police.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Git Police

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
git-police:
name: Git Police
if: github.head_ref != 'develop'
runs-on: ubuntu-latest
env:
PR_ID: ${{ github.event.pull_request.number }}
REPO_NAME: ${{ github.event.repository.name }}
ETENDOBOT_TOKEN: ${{ secrets.ETENDOBOT_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Docker container
id: run-docker
run: |
printenv
echo "-------------------------------------------------------------------------"
echo ${{ env.DOCKERHUB_PASSWORD }} | docker login --username "${{ env.DOCKERHUB_USERNAME }}" --password-stdin
docker run -d -p 5000:5000 -e REPO_TOKEN="${{ env.ETENDOBOT_TOKEN }}" -e PR_ID=${{ env.PR_ID }} -e REPO_NAME=${{ env.REPO_NAME }} etendo/gitpolice:latest
- name: Git Police API call
id: call-api
run: |
sleep 10s
response=$(curl -s -o response.txt -w "%{http_code}" -X GET http://localhost:5000/api/github)
if [ $response -ne 200 ]; then
echo "API call failed with status code $response. This is likely an error related to the PR data, or an internal API error"
echo "Response text:"
cat response.txt
exit 1
fi
if ! grep -q "Valid branch name and correct destination" response.txt; then
echo "Git Police check failed: response does not contain 'Valid branch name and correct destination'"
echo "Full response:"
cat response.txt
exit 1
fi
echo "API call successful with status code $response"
echo "Response text:"
cat response.txt
7 changes: 3 additions & 4 deletions .github/workflows/snyk-code-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ on:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_run:
workflows: [Git Police]
types: [completed]

jobs:
snyk:
Expand Down

0 comments on commit c663441

Please sign in to comment.