Skip to content

Commit

Permalink
fix workflow - wrong check team members
Browse files Browse the repository at this point in the history
  • Loading branch information
ivvist committed May 26, 2024
1 parent d7ef469 commit fa59a73
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,18 @@ jobs:
secrets:
git_token: ${{ secrets.REPOREADING_TOKEN }}

handle-failure:
needs: make-rc
runs-on: ubuntu-latest
if: failure()
steps:
- name: Add comment to issue
env:
GH_TOKEN: ${{ secrets.REPOREADING_TOKEN }}
org: 'IVVORG'
repo: 'public-test-repo'
user: '${{ github.event.issue.user.login }}'
issue: '${{ github.event.issue.number }}'
body: "Error occured"
run: |
curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/add-issue-commit.sh | bash
98 changes: 98 additions & 0 deletions .github/workflows/rc1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Make release candidate

on:
workflow_call:
inputs:
org:
required: true
type: string
repo:
required: true
type: string
team:
required: true
type: string
user:
required: true
type: string
issue:
required: true
type: string
secrets:
git_token:
required: true

jobs:
make_rc:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main # Checkout the main branch

- name: Add comment to issue
env:
GH_TOKEN: ${{ secrets.git_token }}
org: ${{ inputs.org }}
repo: ${{ inputs.repo }}
issue: ${{ inputs.issue }}
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/add-issue-commit.sh | bash
- name: Check Issue
run: |
echo "org: ${{ inputs.org }}"
echo "team: ${{ inputs.team }}"
echo "user: ${{ inputs.user }}"
echo "title: ${{ inputs.issue-title }}"
ORG_NAME=${{ inputs.org }}
TEAM_NAME=${{ inputs.team }}
USER_NAME=${{ inputs.user }}
echo "org1: $ORG_NAME"
echo "team1: $TEAM_NAME"
echo "user1: $USER_NAME"
# Check organization membership
ORG_MEMBERSHIP=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.git_token }}" "https://api.github.com/orgs/$ORG_NAME/members/$USER_NAME")

if [[ $ORG_MEMBERSHIP -ne 404 ]]; then
echo "The user $USER_NAME is a member of the organization $ORG_NAME."
else
echo "The user $USER_NAME is not a member of the organization $ORG_NAME."
exit 1
fi

# Check team membership
TEAM_MEMBERSHIP=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.git_token }}" "https://api.github.com/orgs/$ORG_NAME/teams/$TEAM_NAME/memberships/$USER_NAME")
echo "$TEAM_MEMBERSHIP"
if [[ $TEAM_MEMBERSHIP -eq 200 ]]; then
echo "The user $USER_NAME is a member of the team $TEAM_NAME within the organization $ORG_NAME."
else
echo "The user $USER_NAME is not a member of the team $TEAM_NAME within the organization $ORG_NAME."
exit 1
fi

# Make RC for the repo here:

- name: Re-create release branch
env:
GH_TOKEN: ${{ secrets.git_token }}
org: ${{ inputs.org }}
repo: ${{ inputs.repo }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "upload-robot"
git config --global url.https://${{ secrets.git_token }}@github.com/.insteadOf https://github.com/
curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/rc.sh | bash
- name: Close issue
env:
GH_TOKEN: ${{ secrets.git_token }}
org: ${{ inputs.org }}
repo: ${{ inputs.repo }}
issue: ${{ inputs.issue }}
run: curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/close-issue.sh | bash

0 comments on commit fa59a73

Please sign in to comment.