From a64c45c2b5adfacdcaf32c717ff5d94323d4a0b9 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:34:40 +0100 Subject: [PATCH] Update build-dev.yml --- .github/workflows/build-dev.yml | 92 ++++++++++----------------------- 1 file changed, 28 insertions(+), 64 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index b06ae635762d..96fac4709b90 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -1,78 +1,42 @@ -name: Dev build +name: Test Org Membership on: workflow_dispatch: inputs: - submodule_path_regex: - description: - Regex of submodule paths to updated to HEAD before building. - default: content-modules + username: + description: "GitHub username to check" + required: true + type: string + org: + description: "GitHub organization name" + required: true type: string jobs: - build-and-test: - name: BUILD and CHECK LINKS + test-membership: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Create NPM cache-hash input file - run: | - mkdir -p tmp - jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json + steps: + - name: Install GitHub CLI + run: sudo apt-get install gh -y - - name: Create and use reduced-dependencies package.json + - name: Check if user is a member of the org + id: check-membership run: | - jq 'del(.dependencies, .optionalDependencies)' \ - package.json > tmp/package-min.json - cp tmp/package-min.json package.json - - - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: npm - cache-dependency-path: tmp/package-ci.json - - - run: npm install --omit=optional - - - run: npm run log:test-and-fix - env: - CMD_SKIP: i18n|registry - GET: no # For details, see: https://opentelemetry.io/docs/contributing/development/#submodule-changes - PIN_SKIP: ${{ inputs.submodule_path_regex }} - - - uses: actions/upload-artifact@v4 - with: - name: build-log-etc - path: | - tmp/build-log.txt - tmp/package*.json - static/refcache.json + USERNAME="${{ inputs.username }}" + ORG="${{ inputs.org }}" + STATUS=$(gh api "orgs/$ORG/members/$USERNAME" -q '.login' || true) + + if [[ "$STATUS" == "$USERNAME" ]]; then + echo "MEMBER_FOUND=true" >> $GITHUB_ENV + else + echo "MEMBER_FOUND=false" >> $GITHUB_ENV + fi - check-refcache: - name: REFCACHE updates? - needs: build-and-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - with: { name: build-log-etc } - - name: Fail when refcache contains entries with HTTP status 4XX + - name: Comment on the check result run: | - if grep -B 1 -e '"StatusCode": 4' static/refcache.json; then - echo "Run 'npx gulp prune' to remove 4xx entries from the refcache" - exit 1 + if [[ "$MEMBER_FOUND" == "true" ]]; then + echo "✅ $USERNAME is a member of the $ORG organization." + else + echo "❌ $USERNAME is NOT a member of the $ORG organization." fi - - name: Does the refcache need updating? - run: npm run diff:fail - - check-build-log-for-issues: - name: WARNINGS in build log? - needs: build-and-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - with: { name: build-log-etc } - - run: cat tmp/build-log.txt - - run: scripts/check-build-log.sh