diff --git a/.github/dco.yml b/.github/dco.yml deleted file mode 100644 index 37e411e1be..0000000000 --- a/.github/dco.yml +++ /dev/null @@ -1,2 +0,0 @@ -require: - members: false \ No newline at end of file diff --git a/.github/workflows/automerge-backport.yml b/.github/workflows/automerge-backport.yml new file mode 100644 index 0000000000..0d33634862 --- /dev/null +++ b/.github/workflows/automerge-backport.yml @@ -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" diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 8f933b2ada..0e70f48eea 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -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' || ( @@ -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 }} diff --git a/.github/workflows/delete_backport_branch.yml b/.github/workflows/delete_backport_branch.yml deleted file mode 100644 index 387a124b8c..0000000000 --- a/.github/workflows/delete_backport_branch.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Delete merged branch of the backport PRs -on: - pull_request: - types: - - closed - -jobs: - delete-branch: - runs-on: ubuntu-latest - if: startsWith(github.event.pull_request.head.ref,'backport/') - steps: - - name: Delete merged branch - uses: SvanBoxel/delete-merged-branch@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/delete_merged_branch.yml b/.github/workflows/delete_merged_branch.yml new file mode 100644 index 0000000000..f6fc3f2828 --- /dev/null +++ b/.github/workflows/delete_merged_branch.yml @@ -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 }} diff --git a/.github/workflows/encoding-check.yml b/.github/workflows/encoding-check.yml new file mode 100644 index 0000000000..ade95e5f37 --- /dev/null +++ b/.github/workflows/encoding-check.yml @@ -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 diff --git a/.github/workflows/jekyll-build.yml b/.github/workflows/jekyll-build.yml index e70385484e..ba50a635aa 100644 --- a/.github/workflows/jekyll-build.yml +++ b/.github/workflows/jekyll-build.yml @@ -3,7 +3,7 @@ name: Jekyll Build Verification on: [pull_request] jobs: - check: + jekyll-build: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 1940a03581..6966d8cdac 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -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