Skip to content

Commit 97e999e

Browse files
Backport main workflows to 2.5 branch (#6899)
* Backport main workflows to 2.5 branch Signed-off-by: Peter Zhu <[email protected]> * Backport main workflows to 2.5 branch Signed-off-by: Peter Zhu <[email protected]> --------- Signed-off-by: Peter Zhu <[email protected]>
1 parent 4fcaeb4 commit 97e999e

8 files changed

+108
-20
lines changed

Diff for: .github/dco.yml

-2
This file was deleted.

Diff for: .github/workflows/automerge-backport.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Automerge Backport
2+
on:
3+
pull_request:
4+
pull_request_review:
5+
types:
6+
- submitted
7+
check_suite:
8+
types:
9+
- completed
10+
status: {}
11+
jobs:
12+
automerge-backport:
13+
if: |
14+
github.repository == 'opensearch-project/documentation-website' &&
15+
startsWith(github.event.pull_request.head.ref, 'backport/')
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Wait some time so that label and approval is up
19+
run: sleep 30
20+
- id: automerge
21+
name: automerge
22+
uses: "pascalgn/[email protected]"
23+
env:
24+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
25+
MERGE_LABELS: "backport-automerge,!On hold"
26+
MERGE_FILTER_AUTHOR: "opensearch-trigger-bot[bot]"
27+
MERGE_REQUIRED_APPROVALS: "1"
28+
MERGE_RETRIES: "20"
29+
MERGE_RETRY_SLEEP: "10000"
30+
MERGE_ERROR_FAIL: "true"
31+
MERGE_FORKS: "false"
32+
MERGE_METHOD: "squash"
33+
MERGE_DELETE_BRANCH: "true"

Diff for: .github/workflows/backport.yml

+23
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
1717
if: >
1818
github.event.pull_request.merged
19+
&& github.repository == 'opensearch-project/documentation-website'
1920
&& (
2021
github.event.action == 'closed'
2122
|| (
@@ -38,3 +39,25 @@ jobs:
3839
with:
3940
github_token: ${{ steps.github_app_token.outputs.token }}
4041
head_template: backport/backport-<%= number %>-to-<%= base %>
42+
43+
- name: Label new backport PR with backport-automerge label
44+
run: |
45+
PR_LABELS=`echo "${{ toJson(github.event.pull_request.labels.*.name) }}" | sed -e 's/\[//g;s/\]//g;s/^\s*//g;s/\s*$//g' | tr -d '\n'`
46+
echo $PR_LABELS
47+
OLDIFS=$IFS
48+
export IFS=','
49+
for label in $PR_LABELS
50+
do
51+
if [[ "$label" == "backport"* ]]; then
52+
echo "Found label \"$label\""
53+
PR_REPO="opensearch-project/documentation-website"
54+
PR_BRANCH=backport/backport-${{ github.event.pull_request.number }}-to-`echo $label | cut -d ' ' -f2`
55+
PR_NUMBER=`gh pr list -R $PR_REPO --json "number,headRefName" --state open | jq -r ".[] | select(.headRefName == \"$PR_BRANCH\") | .number"`
56+
echo "Update Backport PR '#$PR_NUMBER' on branch '$PR_BRANCH' with 'backport-automerge' label"
57+
gh issue edit -R $PR_REPO $PR_NUMBER --add-label backport-automerge
58+
echo "Auto approve $PR_REPO PR #$PR_NUMBER with opensearch-trigger-bot"
59+
gh pr review -R $PR_REPO $PR_NUMBER --approve
60+
fi
61+
done
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .github/workflows/delete_backport_branch.yml

-15
This file was deleted.

Diff for: .github/workflows/delete_merged_branch.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Delete merged branch of the PRs
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
7+
jobs:
8+
delete-branch:
9+
runs-on: ubuntu-latest
10+
if: |
11+
github.repository == 'opensearch-project/documentation-website' &&
12+
${{ !startsWith(github.event.pull_request.head.ref, 'main') }} &&
13+
${{ !startsWith(github.event.pull_request.head.ref, '1.') }} &&
14+
${{ !startsWith(github.event.pull_request.head.ref, '2.') }} &&
15+
${{ !startsWith(github.event.pull_request.head.ref, 'version/') }}
16+
steps:
17+
- name: Echo remove branch
18+
run: echo Removing ${{github.event.pull_request.head.ref}}
19+
- name: Delete merged branch
20+
uses: SvanBoxel/delete-merged-branch@main
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .github/workflows/encoding-check.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Encoding Checker
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
encoding-checker:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repository
10+
uses: actions/checkout@v3
11+
- name: Check for possible file that does not follow utf-8 encoding
12+
run: |
13+
set +e
14+
IFS=$(echo -en "\n\b")
15+
COUNTER=0
16+
for i in `find . -type f \( -name "*.txt" -o -name "*.md" -o -name "*.markdown" -o -name "*.html" \) | grep -vE "^./.git"`;
17+
do
18+
grep -axv '.*' "$i"
19+
if [ "$?" -eq 0 ]; then
20+
echo -e "######################\n$i\n######################"
21+
COUNTER=$(( COUNTER + 1 ))
22+
fi
23+
done
24+
if [ "$COUNTER" != 0 ]; then
25+
echo "Found files that is not following utf-8 encoding, exit 1"
26+
exit 1
27+
fi

Diff for: .github/workflows/jekyll-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Jekyll Build Verification
33
on: [pull_request]
44

55
jobs:
6-
check:
6+
jekyll-build:
77
runs-on: ubuntu-latest
88

99
steps:

Diff for: .github/workflows/link-checker.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
schedule:
55
- cron: "30 11 * * 0"
66
jobs:
7-
check:
8-
if: github.repository == opensearch-project/documentation-website
7+
link-checker:
8+
if: github.repository == 'opensearch-project/documentation-website'
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3

0 commit comments

Comments
 (0)