update workflow #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 user | ||
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." | ||
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/ | ||
chmod +x https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/rc.sh | ||
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 | ||