Skip to content

Commit

Permalink
Backport main workflows to 2.2 branch (#6896)
Browse files Browse the repository at this point in the history
* Backport main workflows to 2.2 branch

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Backport main workflows to 2.2 branch

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

---------

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon committed Apr 5, 2024
1 parent 4f4487f commit df67ed5
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 36 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/automerge-backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Automerge Backport
on:
pull_request:
pull_request_review:
types:
- submitted
check_suite:
types:
- completed
status: {}
jobs:
automerge-backport:
if: |
github.repository == 'opensearch-project/documentation-website' &&
startsWith(github.event.pull_request.head.ref, 'backport/')
runs-on: ubuntu-latest
steps:
- name: Wait some time so that label and approval is up
run: sleep 30
- id: automerge
name: automerge
uses: "pascalgn/automerge-action@v0.16.2"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: "backport-automerge,!On hold"
MERGE_FILTER_AUTHOR: "opensearch-trigger-bot[bot]"
MERGE_REQUIRED_APPROVALS: "1"
MERGE_RETRIES: "20"
MERGE_RETRY_SLEEP: "10000"
MERGE_ERROR_FAIL: "true"
MERGE_FORKS: "false"
MERGE_METHOD: "squash"
MERGE_DELETE_BRANCH: "true"
23 changes: 23 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& github.repository == 'opensearch-project/documentation-website'
&& (
github.event.action == 'closed'
|| (
Expand All @@ -38,3 +39,25 @@ jobs:
with:
github_token: ${{ steps.github_app_token.outputs.token }}
head_template: backport/backport-<%= number %>-to-<%= base %>

- name: Label new backport PR with backport-automerge label
run: |
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'`
echo $PR_LABELS
OLDIFS=$IFS
export IFS=','
for label in $PR_LABELS
do
if [[ "$label" == "backport"* ]]; then
echo "Found label \"$label\""
PR_REPO="opensearch-project/documentation-website"
PR_BRANCH=backport/backport-${{ github.event.pull_request.number }}-to-`echo $label | cut -d ' ' -f2`
PR_NUMBER=`gh pr list -R $PR_REPO --json "number,headRefName" --state open | jq -r ".[] | select(.headRefName == \"$PR_BRANCH\") | .number"`
echo "Update Backport PR '#$PR_NUMBER' on branch '$PR_BRANCH' with 'backport-automerge' label"
gh issue edit -R $PR_REPO $PR_NUMBER --add-label backport-automerge
echo "Auto approve $PR_REPO PR #$PR_NUMBER with opensearch-trigger-bot"
gh pr review -R $PR_REPO $PR_NUMBER --approve
fi
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 0 additions & 18 deletions .github/workflows/dco.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/delete_backport_branch.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/delete_merged_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Delete merged branch of the PRs
on:
pull_request:
types:
- closed

jobs:
delete-branch:
runs-on: ubuntu-latest
if: |
github.repository == 'opensearch-project/documentation-website' &&
${{ !startsWith(github.event.pull_request.head.ref, 'main') }} &&
${{ !startsWith(github.event.pull_request.head.ref, '1.') }} &&
${{ !startsWith(github.event.pull_request.head.ref, '2.') }} &&
${{ !startsWith(github.event.pull_request.head.ref, 'version/') }}
steps:
- name: Echo remove branch
run: echo Removing ${{github.event.pull_request.head.ref}}
- name: Delete merged branch
uses: SvanBoxel/delete-merged-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/encoding-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Encoding Checker

on: [pull_request]

jobs:
encoding-checker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check for possible file that does not follow utf-8 encoding
run: |
set +e
IFS=$(echo -en "\n\b")
COUNTER=0
for i in `find . -type f \( -name "*.txt" -o -name "*.md" -o -name "*.markdown" -o -name "*.html" \) | grep -vE "^./.git"`;
do
grep -axv '.*' "$i"
if [ "$?" -eq 0 ]; then
echo -e "######################\n$i\n######################"
COUNTER=$(( COUNTER + 1 ))
fi
done
if [ "$COUNTER" != 0 ]; then
echo "Found files that is not following utf-8 encoding, exit 1"
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/jekyll-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Jekyll Build Verification
on: [pull_request]

jobs:
check:
jekyll-build:
runs-on: ubuntu-latest

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
schedule:
- cron: "30 11 * * 0"
jobs:
check:
if: github.repository == opensearch-project/documentation-website
link-checker:
if: github.repository == 'opensearch-project/documentation-website'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit df67ed5

Please sign in to comment.