|
1 |
| -name: Dev build |
| 1 | +name: Test Org Membership |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_dispatch:
|
5 | 5 | inputs:
|
6 |
| - submodule_path_regex: |
7 |
| - description: |
8 |
| - Regex of submodule paths to updated to HEAD before building. |
9 |
| - default: content-modules |
| 6 | + username: |
| 7 | + description: "GitHub username to check" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + org: |
| 11 | + description: "GitHub organization name" |
| 12 | + required: true |
10 | 13 | type: string
|
11 | 14 |
|
12 | 15 | jobs:
|
13 |
| - build-and-test: |
14 |
| - name: BUILD and CHECK LINKS |
| 16 | + test-membership: |
15 | 17 | runs-on: ubuntu-latest
|
16 |
| - steps: |
17 |
| - - uses: actions/checkout@v4 |
18 | 18 |
|
19 |
| - - name: Create NPM cache-hash input file |
20 |
| - run: | |
21 |
| - mkdir -p tmp |
22 |
| - jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json |
| 19 | + steps: |
| 20 | + - name: Install GitHub CLI |
| 21 | + run: sudo apt-get install gh -y |
23 | 22 |
|
24 |
| - - name: Create and use reduced-dependencies package.json |
| 23 | + - name: Check if user is a member of the org |
| 24 | + id: check-membership |
25 | 25 | run: |
|
26 |
| - jq 'del(.dependencies, .optionalDependencies)' \ |
27 |
| - package.json > tmp/package-min.json |
28 |
| - cp tmp/package-min.json package.json |
29 |
| -
|
30 |
| - - uses: actions/setup-node@v4 |
31 |
| - with: |
32 |
| - node-version-file: .nvmrc |
33 |
| - cache: npm |
34 |
| - cache-dependency-path: tmp/package-ci.json |
35 |
| - |
36 |
| - - run: npm install --omit=optional |
37 |
| - |
38 |
| - - run: npm run log:test-and-fix |
39 |
| - env: |
40 |
| - CMD_SKIP: i18n|registry |
41 |
| - GET: no # For details, see: https://opentelemetry.io/docs/contributing/development/#submodule-changes |
42 |
| - PIN_SKIP: ${{ inputs.submodule_path_regex }} |
43 |
| - |
44 |
| - - uses: actions/upload-artifact@v4 |
45 |
| - with: |
46 |
| - name: build-log-etc |
47 |
| - path: | |
48 |
| - tmp/build-log.txt |
49 |
| - tmp/package*.json |
50 |
| - static/refcache.json |
| 26 | + USERNAME="${{ inputs.username }}" |
| 27 | + ORG="${{ inputs.org }}" |
| 28 | + STATUS=$(gh api "orgs/$ORG/members/$USERNAME" -q '.login' || true) |
| 29 | + |
| 30 | + if [[ "$STATUS" == "$USERNAME" ]]; then |
| 31 | + echo "MEMBER_FOUND=true" >> $GITHUB_ENV |
| 32 | + else |
| 33 | + echo "MEMBER_FOUND=false" >> $GITHUB_ENV |
| 34 | + fi |
51 | 35 |
|
52 |
| - check-refcache: |
53 |
| - name: REFCACHE updates? |
54 |
| - needs: build-and-test |
55 |
| - runs-on: ubuntu-latest |
56 |
| - steps: |
57 |
| - - uses: actions/checkout@v4 |
58 |
| - - uses: actions/download-artifact@v4 |
59 |
| - with: { name: build-log-etc } |
60 |
| - - name: Fail when refcache contains entries with HTTP status 4XX |
| 36 | + - name: Comment on the check result |
61 | 37 | run: |
|
62 |
| - if grep -B 1 -e '"StatusCode": 4' static/refcache.json; then |
63 |
| - echo "Run 'npx gulp prune' to remove 4xx entries from the refcache" |
64 |
| - exit 1 |
| 38 | + if [[ "$MEMBER_FOUND" == "true" ]]; then |
| 39 | + echo "✅ $USERNAME is a member of the $ORG organization." |
| 40 | + else |
| 41 | + echo "❌ $USERNAME is NOT a member of the $ORG organization." |
65 | 42 | fi
|
66 |
| - - name: Does the refcache need updating? |
67 |
| - run: npm run diff:fail |
68 |
| - |
69 |
| - check-build-log-for-issues: |
70 |
| - name: WARNINGS in build log? |
71 |
| - needs: build-and-test |
72 |
| - runs-on: ubuntu-latest |
73 |
| - steps: |
74 |
| - - uses: actions/checkout@v4 |
75 |
| - - uses: actions/download-artifact@v4 |
76 |
| - with: { name: build-log-etc } |
77 |
| - - run: cat tmp/build-log.txt |
78 |
| - - run: scripts/check-build-log.sh |
0 commit comments