Skip to content

Commit 152c53f

Browse files
committed
build and push agents workflow
1 parent d44c2f2 commit 152c53f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

.github/workflows/build-and-push-tutorial-agent.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
rebuild_all:
7-
description: "Rebuild all agents regardless of changes"
7+
description: "Rebuild all tutorial agents regardless of changes, this is reserved for maintainers only."
88
required: false
99
type: boolean
1010
default: false
@@ -24,8 +24,29 @@ permissions:
2424
packages: write
2525

2626
jobs:
27+
check-permissions:
28+
if: ${{ github.event_name == 'workflow_dispatch' }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Check if user is maintainer
32+
uses: actions/github-script@v7
33+
with:
34+
script: |
35+
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
username: context.actor
39+
});
40+
41+
const allowedRoles = ['admin', 'maintain'];
42+
if (!allowedRoles.includes(permission.permission)) {
43+
throw new Error(`❌ User ${context.actor} does not have sufficient permissions. Required: ${allowedRoles.join(', ')}. Current: ${permission.permission}`);
44+
}
45+
2746
find-agents:
2847
runs-on: ubuntu-latest
48+
needs: [check-permissions]
49+
if: ${{ !cancelled() && !failure() }}
2950
outputs:
3051
agents: ${{ steps.get-agents.outputs.agents }}
3152
has_agents: ${{ steps.get-agents.outputs.has_agents }}
@@ -157,7 +178,7 @@ jobs:
157178
echo "🚀 Building and pushing agent: ${{ matrix.agent_path }}"
158179
else
159180
SHOULD_PUSH=false
160-
VERSION_TAG="pr-${{ github.event.number }}"
181+
VERSION_TAG="${{ github.commit.sha }}"
161182
echo "🔍 Validating build for agent: ${{ matrix.agent_path }}"
162183
fi
163184

0 commit comments

Comments
 (0)