Skip to content

Commit ce5749a

Browse files
authored
backport workflow updates from 1.3+ in... (#603)
1 parent 703cb20 commit ce5749a

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
<!--- If your changes apply to the latest released and/or in-development version of RHDH, open your PR against the `main` branch and cherrypick your PR to any released branches that you want to apply your changes to. --->
44

5+
**IMPORTANT: Do Not Merge - To be merged by Docs Team Only**
6+
57
**Version(s):**
68
<!--- Specify the version(s) of RHDH that your PR applies to. -->
79

@@ -15,6 +17,7 @@
1517
- [ ] SME: @ mention assignee
1618
- [ ] QE: @ mention assignee
1719
- [ ] Docs review: @ mention assignee
20+
- [ ] Additional review: @mention assignee (by writer)
1821
<!--- SME approval is required to merge a PR unless the changes are made by a subject matter expert. --->
1922
<!--- QE approval is required to merge a PR unless there are no technical changes to the content. --->
2023
<!--- Docs team approval is required for ALL PRs. --->

.github/workflows/build-asciidoc.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
- main
2222
- rhdh-1.**
2323
- 1.**.x
24+
- release-1.**
2425

2526
jobs:
2627
adoc_build:
@@ -75,11 +76,11 @@ jobs:
7576
PR_JSON=$(curl -sSL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" "$PULL_URL/$PR")
7677
if [[ $(echo "$PR_JSON" | grep merged\") == *"merged\": true"* ]]; then
7778
echo "merged, can delete from pulls.html and remove folder $d"
78-
git rm -fr --quiet $d || rm -fr $d
79+
git rm -fr --quiet "pr-${d}" || rm -fr "pr-${d}"
7980
sed -r -e "/pr-$PR\/index.html>pr-$PR</d" -i pulls.html
8081
elif [[ $(echo "$PR_JSON" | grep \"state\") == *"state\": \"closed\""* ]]; then
81-
echo "closed, can delete from pulls.html and remove folder $d"
82-
git rm -fr --quiet $d || rm -fr $d
82+
echo "closed, can delete from pulls.html and remove folder pr-${d}"
83+
git rm -fr --quiet "pr-${d}" || rm -fr "pr-${d}"
8384
sed -r -e "/pr-$PR\/index.html>pr-$PR</d" -i pulls.html
8485
else
8586
echo "PR is not closed or merged (or could not read API)"

.github/workflows/pr.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ on:
2727
- main
2828
- rhdh-1.**
2929
- 1.**.x
30+
- release-1.**
3031

3132
concurrency:
3233
group: ${{ github.workflow }}-${{ github.event.number || github.event.pull_request.head.ref }}
@@ -76,6 +77,10 @@ jobs:
7677
echo "Building PR ${{ github.event.pull_request.number }}"
7778
build/scripts/build.sh -b "pr-${{ github.event.number }}"
7879
80+
- name: Pull from origin before pushing (if possible)
81+
run: |
82+
/usr/bin/git pull origin gh-pages || true
83+
7984
# repo must be public for this to work
8085
- name: Deploy
8186
uses: peaceiris/actions-gh-pages@v4
@@ -86,14 +91,19 @@ jobs:
8691
keep_files: true
8792
publish_dir: ./titles-generated
8893

89-
- name: PR comment with doc preview
90-
uses: actions/github-script@v7
91-
with:
92-
github-token: ${{ secrets.RHDH_BOT_TOKEN }}
93-
script: |
94-
github.rest.issues.createComment({
95-
issue_number: context.issue.number,
96-
owner: context.repo.owner,
97-
repo: context.repo.repo,
98-
body: 'PR Preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${{ github.event.number }}/'
99-
});
94+
- name: PR comment with doc preview, replacing existing comments with a new one each time
95+
shell: bash
96+
env:
97+
GH_TOKEN: ${{ secrets.RHDH_BOT_TOKEN }}
98+
run: |
99+
PR_NUM="${{ github.event.number }}"
100+
ORG_REPO="${{ github.repository_owner }}/${{ github.event.repository.name }}"
101+
gh repo set-default "${ORG_REPO}"
102+
# for a given PR, check for existing comments from rhdh-bot; select the last one (if more than one)
103+
if [[ $(gh api "repos/${ORG_REPO}/issues/${PR_NUM}/comments" -q 'map(select(.user.login=="rhdh-bot"))|last|.id') ]]; then
104+
# edit that comment:
105+
gh pr comment ${PR_NUM} -R "${ORG_REPO}" --edit-last --body "Updated preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${PR_NUM}/ @ $(date "+%x %X")"
106+
else
107+
# or create a new one:
108+
gh pr comment ${PR_NUM} -R "${ORG_REPO}" --body "Preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${PR_NUM}/"
109+
fi

0 commit comments

Comments
 (0)