diff --git a/.github/scripts/check_team_membership.sh b/.github/scripts/check_team_membership.sh index 51c958d4..6af1f506 100755 --- a/.github/scripts/check_team_membership.sh +++ b/.github/scripts/check_team_membership.sh @@ -1,12 +1,22 @@ #!/bin/bash +set -x + USER=$1 -TOKEN=$2 -response=$(curl -s -H "Authorization: token $TOKEN" "https://api.github.com/orgs/immutable/teams/sdk/memberships/$USER") +response=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "/orgs/immutable/teams/sdk/memberships/${USER}") + +echo "$response" -if echo "$response" | grep -q '"state": "active"'; then - echo "true" +if echo "$response" | grep -q '"state":"active"'; then + IS_MEMBER=true else - echo "false" + IS_MEMBER=false fi +echo "$IS_MEMBER" + +# Set the environment variable for the GitHub workflow +echo "IS_MEMBER=$IS_MEMBER" >> "$GITHUB_ENV" diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml index 1f8d501f..d841e87d 100644 --- a/.github/workflows/update-version.yml +++ b/.github/workflows/update-version.yml @@ -11,19 +11,24 @@ on: jobs: update: runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.UNITY_IMMUTABLE_SDK_GITHUB_TOKEN }} steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Check team membership id: check_team run: | - IS_MEMBER=$(./.github/scripts/check_team_membership.sh "${{ github.actor }}" "${{ secrets.GITHUB_TOKEN }}") + ./.github/scripts/check_team_membership.sh "${{ github.actor }}" "${{ secrets.UNITY_IMMUTABLE_SDK_GITHUB_TOKEN }}" + # shellcheck disable=SC1090 + source "$GITHUB_ENV" + echo "${{ github.actor }} is a member of the SDK team: $IS_MEMBER" if [[ "$IS_MEMBER" != "true" ]]; then echo "Not a member of the SDK team, skipping update" exit 1 fi - - name: Checkout code - uses: actions/checkout@v3 - - name: Set up Python uses: actions/setup-python@v4 with: @@ -54,4 +59,4 @@ jobs: body: "Update version in package.json" branch: "release/update-version" commit-message: "release: update version" - labels: release \ No newline at end of file + labels: release