Skip to content

Commit 856b5cb

Browse files
committed
added workflow to automatically execute prs in texera
1 parent f899929 commit 856b5cb

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/github-action-build.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,56 @@ on:
2626
- 'ci-enable/**'
2727
- 'main'
2828
pull_request:
29+
types: [opened, synchronize, reopened]
2930
workflow_dispatch:
3031

3132
concurrency:
3233
group: ${{ github.workflow }}-${{ github.ref }}
3334
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
3435

3536
jobs:
37+
check-permissions:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v5
42+
with:
43+
fetch-depth: 0
44+
- name: Get changed files
45+
id: changed-files
46+
run: |
47+
if [ "${{ github.event_name }}" == "pull_request" ]; then
48+
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -c "^\.github/workflows/github-action-build\.yml$" || true)
49+
if [ "$CHANGED" -gt "0" ]; then
50+
echo "any_changed=true" >> $GITHUB_OUTPUT
51+
else
52+
echo "any_changed=false" >> $GITHUB_OUTPUT
53+
fi
54+
else
55+
echo "any_changed=false" >> $GITHUB_OUTPUT
56+
fi
57+
- name: Check if actor is a committer
58+
id: check-committer
59+
if: steps.changed-files.outputs.any_changed == 'true'
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission --jq '.permission' 2>/dev/null || echo "none")
64+
if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "maintain" || "$PERMISSION" == "write" ]]; then
65+
echo "is_committer=true" >> $GITHUB_OUTPUT
66+
else
67+
echo "is_committer=false" >> $GITHUB_OUTPUT
68+
fi
69+
- name: Require approval if workflow changed
70+
if: |
71+
steps.changed-files.outputs.any_changed == 'true' &&
72+
steps.check-committer.outputs.is_committer == 'false'
73+
run: |
74+
echo "::error::This PR modifies the build workflow. A committer must review and re-run this workflow manually."
75+
exit 1
76+
3677
frontend:
78+
needs: check-permissions
3779
runs-on: ${{ matrix.os }}
3880
strategy:
3981
matrix:
@@ -81,6 +123,7 @@ jobs:
81123
run: yarn --cwd frontend run build:ci
82124

83125
scala:
126+
needs: check-permissions
84127
strategy:
85128
matrix:
86129
os: [ ubuntu-22.04 ]
@@ -97,7 +140,6 @@ jobs:
97140
POSTGRES_PASSWORD: postgres
98141
ports:
99142
- 5432:5432
100-
# Add a health check so steps wait until Postgres is ready
101143
options: >-
102144
--health-cmd="pg_isready -U postgres"
103145
--health-interval=10s
@@ -145,6 +187,7 @@ jobs:
145187
run: sbt test
146188

147189
python:
190+
needs: check-permissions
148191
strategy:
149192
matrix:
150193
os: [ ubuntu-latest ]

0 commit comments

Comments
 (0)