-
Notifications
You must be signed in to change notification settings - Fork 17
88 lines (79 loc) · 2.81 KB
/
pr-tarball.yml
File metadata and controls
88 lines (79 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: PR Tarball
on:
pull_request_target:
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
authorize:
runs-on: ubuntu-latest
outputs:
is_authorized: ${{ steps.check.outputs.is_authorized }}
steps:
- name: Check authorization
id: check
run: |
AUTHORIZED_USERS="${{ secrets.AUTHORIZED_USERS }}"
if [[ ",$AUTHORIZED_USERS," == *",${{ github.actor }},"* ]]; then
echo "✅ User ${{ github.actor }} is authorized"
echo "is_authorized=true" >> "$GITHUB_OUTPUT"
else
echo "⏭️ User ${{ github.actor }} is not in AUTHORIZED_USERS — skipping."
echo "is_authorized=false" >> "$GITHUB_OUTPUT"
fi
pr-tarball:
needs: authorize
if: needs.authorize.outputs.is_authorized == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v6
with:
node-version: '20.x'
cache: 'npm'
- name: Configure git
run: |
git config --global user.email "bedrock-agentcore-npm+ci@amazon.com"
git config --global user.name "CI"
- uses: astral-sh/setup-uv@v7
- run: npm ci
- run: npm run build --if-present
- run: npm pack
- name: Get tarball info
id: tarball
run: |
TARBALL_NAME=$(ls *.tgz | head -1 | xargs basename)
echo "name=$TARBALL_NAME" >> $GITHUB_OUTPUT
- name: Create or update PR release
id: release
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
TARBALL_NAME: ${{ steps.tarball.outputs.name }}
run: |
TAG="pr-${PR_NUMBER}-tarball"
# Delete existing release if it exists (to update the tarball)
gh release delete "$TAG" --yes --cleanup-tag 2>/dev/null || true
# Create a new pre-release with the tarball
gh release create "$TAG" \
"${TARBALL_NAME}" \
--title "PR #${PR_NUMBER} Tarball" \
--notes "Auto-generated tarball for PR #${PR_NUMBER}." \
--draft \
--target "${{ github.event.pull_request.head.sha }}"
DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/${TARBALL_NAME}"
echo "url=$DOWNLOAD_URL" >> $GITHUB_OUTPUT
- name: Comment on PR
uses: marocchino/sticky-pull-request-comment@v3
with:
header: tarball
message: |
## Package Tarball
**[${{ steps.tarball.outputs.name }}](${{ steps.release.outputs.url }})**
### How to install
```bash
npm install ${{ steps.release.outputs.url }}
```