-
Notifications
You must be signed in to change notification settings - Fork 7
fix(actions): improve onboarding messaging & remove invalid token check #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
61cd44f
e3f322b
b1070ae
dec590c
b487322
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,15 +22,20 @@ jobs: | |
| TEAM_SLUG: "codeheat" | ||
|
|
||
| steps: | ||
| - name: Debug secret presence | ||
| run: | | ||
| if [ -z "${{ secrets.ORG_ADMIN_TOKEN }}" ]; then | ||
| echo "❌ ORG_ADMIN_TOKEN is NOT available" | ||
| exit 1 | ||
| else | ||
| echo "✅ ORG_ADMIN_TOKEN is available" | ||
| fi | ||
|
|
||
| - name: Invite user to org and team | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.ORG_ADMIN_TOKEN }} | ||
| script: | | ||
| // Validate that the token is present | ||
| if (!github.token || github.token.trim() === "") { | ||
| throw new Error("ORG_ADMIN_TOKEN is missing or empty. Please set the required secret."); | ||
| } | ||
| const org = process.env.ORG_NAME; | ||
| const team_slug = process.env.TEAM_SLUG; | ||
| const issue = context.payload.issue; | ||
|
|
@@ -71,18 +76,22 @@ jobs: | |
|
|
||
| // ---- Org membership ---- | ||
| let membership; | ||
| let invited = false; | ||
|
|
||
| try { | ||
| membership = await github.rest.orgs.getMembershipForUser({ | ||
| org, | ||
| username, | ||
| }); | ||
| } catch (error) { | ||
| if (error.status !== 404) throw error; | ||
Ubayed-Bin-Sufian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| membership = await github.rest.orgs.setMembershipForUser({ | ||
| org, | ||
| username | ||
| username, | ||
| }); | ||
| } catch (err) { | ||
| await comment( | ||
| `❌ **Failed to invite @${username} to ${org}**\n\n` + | ||
| `Error: ${err.message}` | ||
| ); | ||
| core.setFailed(err.message); | ||
| return; | ||
|
|
||
| invited = true; | ||
| } | ||
Ubayed-Bin-Sufian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // ---- Team membership (non-fatal) ---- | ||
|
|
@@ -99,15 +108,21 @@ jobs: | |
| ); | ||
| } | ||
|
|
||
| const orgStatusLine = invited | ||
| ? `• Org invitation: **${membership.data.state}**\n` | ||
| : `• Org membership: **already active**\n`; | ||
|
Comment on lines
+131
to
+133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Org membership text can be incorrect for existing but pending members. When |
||
|
|
||
| const teamStatusLine = teamMembership | ||
| ? `• Team membership: **${teamMembership.data.state}**\n` | ||
| : `• Team membership: ❌ **failed** - please add manually to \`${team_slug}\`\n`; | ||
|
|
||
| await comment( | ||
| `✅ **Onboarding processed for @${username}**\n\n` + | ||
| `• Org membership: **${membership.data.state}**\n` + | ||
| `✅ **Onboarding request processed for @${username}**\n\n` + | ||
| orgStatusLine + | ||
| teamStatusLine + | ||
| `\nIf any status is **pending**, please accept the GitHub invitation.` | ||
| (invited | ||
| ? `\nℹ️ Please accept the GitHub invitation from your notifications or email.` | ||
| : `\nℹ️ You are already a member. No further action is required.`) | ||
Ubayed-Bin-Sufian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| // ---- Close issue (non-fatal) ---- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.