Skip to content

Commit

Permalink
Merge pull request #3273 from zowe/anax-test-branch
Browse files Browse the repository at this point in the history
Anax test branch
  • Loading branch information
anaxceron authored Jan 4, 2024
2 parents 94342e6 + 59bbd1c commit 40f0c55
Show file tree
Hide file tree
Showing 8 changed files with 296 additions and 12 deletions.
13 changes: 13 additions & 0 deletions .github/pr-comments/for-community.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
:smiley_cat: Thank you for creating this PR!

Certain labels are needed to open a pull request in the `docs-site` repo, but it looks like you may not be able to add labels. That's because you either do not have permissions or you are using a fork in your PR. To publish your content to [Zowe Docs](https://docs.zowe.org/), follow these steps.

- [ ] Use comments to add labels to your pull request. Enter the `/labels` command in a comment to add the required `review`, `area`, and `release` label types.
- Example: Enter `/labels doc cli V2` to add the `review: doc`, `area: cli`, and `version: V2` labels to your PR.
- The `review` label indicates the kind of review your content requires. The `area` label indicates the content topic area. The `release` labels tells us the major release aligned with your content.
- See the [docs-site labels](https://github.com/zowe/docs-site/issues/labels) to see the labels are available for use.
- To remove a label, use the minus sign: `/labels -V2`
- [ ] Select the `master` branch if your PR updates content that is on the **live site**. Select `docs-staging` if your PR updates content for a future release. Use the `v3-doc-branch` for Zowe V3 content.
- [ ] Notify the Doc Squad about this PR. If you don't know whom should review your content, message the [#zowe-doc](https://openmainframeproject.slack.com/archives/CC961JYMQ) Slack channel. If you know which Doc Squad writer should approve your content, add that person as a reviewer.

**Need help?** Contact the Doc Squad in the [#zowe-doc](https://openmainframeproject.slack.com/archives/CC961JYMQ) Slack channel.
10 changes: 10 additions & 0 deletions .github/pr-comments/for-labeller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:smiley_cat: Thank you for creating this PR! To publish your content to [Zowe Docs](https://docs.zowe.org/), follow these required steps.

- [ ] Add the label `review: doc`.
- [ ] Identify your content topic with a label. (Examples: `area: apiml`, `area: cli`, `area: install and config`, etc.)
- [ ] Specify the major Zowe release(s) for your content. (Examples: `release: V1`, `release: V2`, `release: V3`)
- [ ] If adding content that needs to be removed from V3 documentation, add the `V3 N/A` tag.
- [ ] Select the `master` branch if your PR updates content that is on the **live site**. Select `docs-staging` if your PR updates content for a future release.
- [ ] Notify the Doc Squad about this PR. If you don't know whom should review your content, message the [#zowe-doc](https://openmainframeproject.slack.com/archives/CC961JYMQ) Slack channel. If you know which Doc Squad writer should approve your content, add that person as a reviewer.

**Need help?** Contact the Doc Squad in the [#zowe-doc](https://openmainframeproject.slack.com/archives/CC961JYMQ) Slack channel.
10 changes: 10 additions & 0 deletions .github/pr-comments/for-writer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:smiley_cat: Thank you for creating this PR! To publish your content to [Zowe Docs](https://docs.zowe.org/), follow these steps.

- [ ] Add the label `review: sme` if an SME needs to check your content.
- [ ] Identify your content topic with a label. (Examples: `area: apiml`, `area: cli`, `area: install and config`, etc.)
- [ ] Specify the major Zowe release(s) for your content. (Examples: `release: V1`, `release: V2`, `release: V3`)
- [ ] If adding content that needs to be removed from V3 documentation, add the `V3 N/A` tag.
- [ ] Link any [Doc Issues](https://github.com/zowe/docs-site/issues) related to this PR.
- [ ] Fix broken links found in your content areas.
- [ ] Notify the SME to review this PR (if applicable).
- [ ] Merge to the `master` branch if your PR updates content that is on the live site. Merge to `docs-staging` if your PR updates content for a future release.
13 changes: 3 additions & 10 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
### Your checklist for this pull request
🚨Please review the [guidelines for contributing](../docs/contribute/contributing.md) to this repository.
Describe your pull request here:

- [ ] If the changes in this PR is part of the next future release, make this pull request against the **docs-staging** branch which will be published at the next release boundary. If the changes in this PR are part of the current release, use the default base branch, **master**. For more information about branches, see https://github.com/zowe/docs-site/tree/master#understanding-the-doc-branches.

- [ ] If this PR relates to GitHub issues in `docs-site` or other repositories, please list in Description, prefixed with **close**, **fix** or **resolve** keywords.

### Description (including links to related git issues)
Please describe your pull request.

:heart:Thank you!
List the file(s) included in this PR:

After creating the PR, follow the instructions in the comments.
2 changes: 1 addition & 1 deletion .github/workflows/link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: "--accept 401,429 --cache --max-cache-age 1d --max-concurrency 64 --no-progress --verbose 'docs/**/*.md'"
args: "--accept 401,403,429 --cache --max-cache-age 1d --max-concurrency 64 --no-progress --verbose 'docs/**/*.md'"
fail: true
80 changes: 80 additions & 0 deletions .github/workflows/pr-comment-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: PR Comment Trigger

on:
issue_comment:
types:
- created

jobs:
pr-comment:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request && github.event.comment.user.login == github.event.issue.user.login }}

steps:
- name: Execute script if PR author commented
uses: actions/github-script@v6
with:
github-token: ${{ secrets.ZOWE_ROBOT_TOKEN }}
script: |
console.log("PR URL:", context.payload.issue.pull_request.url);
console.log("PR author:", context.payload.issue.user.login);
console.log("Comment author:", context.payload.comment.user.login);
const body = context.payload.comment.body;
if (body.startsWith("/labels ")) {
console.log("Comment body:", body);
const repoLabels = (await github.rest.issues.listLabelsForRepo(context.repo)).data.map((label) => label.name);
const labelMapping = {};
for (const label of repoLabels) {
if (label.includes(": ")) {
console.log("Found repo label:", label);
labelMapping[label.replace(" ", "")] = label;
labelMapping[label.slice(label.indexOf(":") + 2)] = label;
}
}
const labelsCurrent = (await github.rest.issues.listLabelsOnIssue({ ...context.repo, issue_number: context.payload.issue.number })).data.map((label) => label.name);
console.log("PR labels:", labelsCurrent.join(", "));
const cmdArgs = body.split(" ").slice(1);
const labelsToAdd = cmdArgs.filter((arg) => !arg.startsWith("-")).map((arg) => arg.startsWith("+") ? arg.slice(1) : arg);
console.log("Labels to add:", labelsToAdd.join(", "));
const labelsToRemove = cmdArgs.filter((arg) => arg.startsWith("-")).map((arg) => arg.slice(1));
console.log("Labels to remove:", labelsToRemove.join(", "));
const labelsInvalid = [];
for (const label of labelsToAdd) {
if (labelMapping[label] == null) {
console.log("Invalid label:", label);
labelsInvalid.push(label);
} else if (labelsCurrent.includes(labelMapping[label])) {
console.log("Skipping label:", labelMapping[label]);
} else {
console.log("Adding label:", labelMapping[label]);
try {
await github.rest.issues.addLabels({ ...context.repo, issue_number: context.payload.issue.number, labels: [labelMapping[label]] });
} catch (err) {
console.log("Failed to add label:", err);
labelsInvalid.push(label);
}
}
}
for (const label of labelsToRemove) {
if (labelMapping[label] == null) {
console.log("Invalid label:", label);
labelsInvalid.push(label);
} else if (!labelsCurrent.includes(labelMapping[label])) {
console.log("Skipping label:", labelMapping[label]);
} else {
console.log("Removing label:", labelMapping[label]);
try {
await github.rest.issues.removeLabel({ ...context.repo, issue_number: context.payload.issue.number, name: labelMapping[label] });
} catch (err) {
console.log("Failed to remove label:", err);
labelsInvalid.push(label);
}
}
}
await github.rest.issues.deleteComment({ ...context.repo, comment_id: context.payload.comment.id });
if (labelsInvalid.length > 0) {
console.log("Invalid labels:", labelsInvalid.join(", "));
const bodyQuoted = body.split("\n").map((line) => "> " + line).join("\n");
await github.rest.issues.createComment({ ...context.repo, issue_number: context.payload.issue.number, body: bodyQuoted + "\n\nThe following labels are invalid: " + labelsInvalid.join(", ") });
}
}
178 changes: 178 additions & 0 deletions .github/workflows/pull-request-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: PR Checker

on:
pull_request_target:
branches:
- docs-staging
- master
- anax-test-branch # TODO Delete this line before merging PR
types: [opened, reopened, edited, labeled]

jobs:
initial-comment:
name: PR Instructions
runs-on: ubuntu-latest
if: github.event.pull_request.user.login != 'zowe-robot'

steps:
# 1. Check out files needed by subsequent steps
- name: Checkout files
uses: actions/checkout@v4
with:
sparse-checkout: .github

# 2. Define outputs used by subsequent steps
- name: Check if author is writer
id: check-if-writer
if: contains(fromJson('["anaxceron", "jandacek", "nannanli", "samanthasusu", "nellietan", "lparadkar-rocket"]'), github.event.pull_request.user.login)
run: echo "PR_AUTHOR_TYPE=writer" >> $GITHUB_ENV

- name: Check if author is labeller
id: check-if-labeller
if: ${{ steps.check-if-writer.outcome == 'skipped' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
response=$(curl -fs -H "Authorization: Token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission")
triage_permission=$(echo "$response" | jq -r '.user.permissions.triage')
if [ "$triage_permission" == "true" ]; then
echo "PR_AUTHOR_TYPE=labeller" >> $GITHUB_ENV
else
echo "PR_AUTHOR_TYPE=community" >> $GITHUB_ENV
fi
# 3. Add initial comment on PR
- name: Add initial comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Initial comment
path: .github/pr-comments/for-${{ env.PR_AUTHOR_TYPE }}.md
only_create: true

# 4. Validate PR description
- name: Description checker
id: description_checker
uses: jadrol/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
template-path: "./.github/pull_request_template.md"
comment: false
- name: Template Not Filled Comment PR
if: failure() && steps.description_checker.outcome == 'failure'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Invalid PR description
message: |
:warning: Looks like something is wrong with the PR description. Remember to add a description and the file(s) included in this PR.
If you have addressed this issue already, refresh this page in your browser to remove this comment.
- name: File type checker
id: file_type_checker
uses: JJ/github-pr-contains-action@releases/v10
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
bodyContains: '\.md|\.jpg|\.gif|\.png'
- name: Missing File Name Comment PR
if: failure() && steps.file_type_checker.outcome == 'failure'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Invalid PR description
message: |
:file_folder: The PR description is missing the file name(s) for the updated content. List all the files included in this PR so this information displays in our [Zowe Docs GitHub Slack channel](https://openmainframeproject.slack.com/archives/C05GH3LT59D).
If you have addressed this issue already, refresh this page in your browser to remove this comment.
- name: Fixed Invalid Description Comment PR
if: success()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Invalid PR description
delete: true

review-labels:
name: Check for missing review label
runs-on: ubuntu-latest
needs: [initial-comment]
if: ${{ always() && !contains(fromJson('["zowe-robot", "anaxceron", "jandacek", "nannanli", "samanthasusu", "nellietan", "lparadkar-rocket"]'), github.event.pull_request.user.login) }}

steps:
- name: Review Label Check
id: prefix_label_check
uses: docker://agilepathway/pull-request-label-checker:latest
with:
prefix_mode: true
any_of: "review:"
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Missing Review Label Comment PR
if: failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Review label missing
message: |
:mag: The **review** label is missing. Add a `review:` label so we can determine who needs to approve this PR.
If you have addressed this issue already, refresh this page in your browser to remove this comment.
- name: Fixed Review Label Comment PR
if: success()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Review label missing
delete: true

release-labels:
name: Check for missing release label
runs-on: ubuntu-latest
needs: [initial-comment]
if: ${{ always() && github.event.pull_request.user.login != 'zowe-robot' }}

steps:
- id: prefix_label_check
uses: docker://agilepathway/pull-request-label-checker:latest
with:
prefix_mode: true
one_of: "release:"
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Missing Release Label Comment PR
if: failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Release label missing
message: |
:floppy_disk: The **release** label is missing. Add a `release:` label so your content is published with the correct major Zowe release.
If you have addressed this issue already, refresh this page in your browser to remove this comment.
- name: Fixed Release Label Comment PR
if: success()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Release label missing
delete: true

area-labels:
name: Check for missing area label
runs-on: ubuntu-latest
needs: [initial-comment]
if: ${{ always() && github.event.pull_request.user.login != 'zowe-robot' }}

steps:
- id: prefix_label_check
uses: docker://agilepathway/pull-request-label-checker:latest
with:
prefix_mode: true
any_of: "area:"
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Missing Area Label Comment PR
if: failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Area label missing
message: |
:pushpin: The **subject area** label is missing. Add an `area:` label so we know what your content is about.
If you have addressed this issue already, refresh this page in your browser to remove this comment.
- name: Fixed Area Label Comment PR
if: success()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Area label missing
delete: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version 2.11.0 (September 2023)
# Version 2.11.0 (September 2023)

Welcome to the Zowe Version 2.11.0 release!

Expand Down

0 comments on commit 40f0c55

Please sign in to comment.