Skip to content

Commit

Permalink
ci: minor fixes in maintainer-tsc management workflow (#838)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
  • Loading branch information
14Richa and derberg authored Aug 10, 2023
1 parent 40f396f commit 02ce996
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
63 changes: 42 additions & 21 deletions .github/workflows/maintainers-tsc-changes-verification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

jobs:
verify-changes:
verify-changes-if-tsc-if-maintainers:
# if statement to check if the PR is open.
if: github.event.pull_request.state == 'open'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -115,43 +115,64 @@ jobs:
errorMessages: ${{ steps.verify-changes.outputs.errorMessages }}
removedTscMembers: ${{ steps.verify-changes.outputs.removedTscMembers }}

handle-human-made-critical-changes:
needs: verify-changes
if: needs.verify-changes.outputs.errorMessages != '[]'
block-human-made-critical-changes:
needs: verify-changes-if-tsc-if-maintainers
if: needs.verify-changes-if-tsc-if-maintainers.outputs.errorMessages != '[]'
runs-on: ubuntu-latest
steps:
- name: Comment and close the PR if there are are any critical changes done by human
- name: Comment and close the PR if there are any critical changes done by human
uses: actions/github-script@v6
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
const rawErrorMessages = `${{ needs.verify-changes.outputs.errorMessages }}`;
const owner = context.repo.owner;
const repo = context.repo.repo;
const pull_number = context.issue.number;
const errorMessages = JSON.parse(rawErrorMessages);
const commentBody = errorMessages.join('\n');
github.rest.issues.createComment({ owner, repo, issue_number: pull_number, body: commentBody });
github.rest.pulls.update({ owner, repo, pull_number, state: 'closed' });
const errorMessages = ${{ needs.verify-changes-if-tsc-if-maintainers.outputs.errorMessages }};
console.log('Parsed errorMessages:', errorMessages);
if (errorMessages && Array.isArray(errorMessages) && errorMessages.length > 0) {
const owner = context.repo.owner;
const repo = context.repo.repo;
const pull_number = context.issue.number;
const commentBody = errorMessages[0];
const commentContext = {
owner: owner,
repo: repo,
issue_number: pull_number,
body: commentBody
};
github.rest.issues.createComment(commentContext);
github.rest.pulls.update({
owner: owner,
repo: repo,
pull_number: pull_number,
state: 'closed'
});
} else {
console.info('rawErrorMessages is empty.');
}
bot-removal-notification:
needs: verify-changes
if: needs.verify-changes.outputs.removedTscMembers != ''
block-bot-from-tsc-removal:
needs: verify-changes-if-tsc-if-maintainers
if: needs.verify-changes-if-tsc-if-maintainers.outputs.removedTscMembers != ''
runs-on: ubuntu-latest
steps:
- name: Comment on PR if TSC member is removed by asyncapi-bot
if: steps.verify-changes.outputs.removedTscMembers != ''
if: steps.verify-changes-if-tsc-if-maintainers.outputs.removedTscMembers != ''
uses: actions/github-script@v6
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
const github = require('@actions/github')
const issueComment = {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
issue_number: github.context.issue.number,
body: 'A TSC member has been removed in this PR. Maintainers of this repository need to review and approve this PR.'
}
github.rest.issues.createComment(issueComment);
const addLabel = {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
issue_number: github.context.issue.number,
labels: ['do-not-merge']
}
github.rest.issues.createComment(issueComment);
github.rest.issues.addLabels(addLabel);
14 changes: 10 additions & 4 deletions .github/workflows/update-website-tsc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#This action update the list of TSC members in the website repository. List of all Maintainers is later rendered in the asyncapi.com website.
name: Update list of Maintainers in the website repo

on:
push:
branches:
- "master"
paths:
- "MAINTAINERS.yaml"

jobs:
update-website:
name: Make PR on website repository with updated maintainers list
Expand Down Expand Up @@ -39,12 +41,16 @@ jobs:
working-directory: ./website
run: |
cp ../community/MAINTAINERS.json ./config/MAINTAINERS.json
- name: Commit and push
- name: Check if there are changes
working-directory: ./website
run: |
git add .
git commit -m "docs(community): update latest maintainers list"
git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website
if ! git diff --quiet; then
git add .
git commit -m "docs(community): update latest maintainers list"
git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website
else
echo "No changes to push."
fi
- name: Create PR
working-directory: ./website
run: |
Expand Down

0 comments on commit 02ce996

Please sign in to comment.