Update OpenSearch Dashboards docs submodule #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update OpenSearch Dashboards docs submodule | |
| on: | |
| push: | |
| branches: | |
| - 2/edge | |
| paths: | |
| - 'docs/**' | |
| workflow_dispatch: | |
| jobs: | |
| update-docs-submodule: | |
| name: Open PR to update OpenSearch Dashboards docs submodule | |
| runs-on: ubuntu-latest | |
| env: | |
| BASE_BRANCH: 2/edge | |
| PR_BRANCH: auto/update-dashboards-docs-submodule-${{ github.sha }} | |
| # Path to the submodule inside the opensearch-operator repository | |
| SUBMODULE_PATH: docs/dashboards | |
| steps: | |
| - name: Checkout target repository | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: canonical/opensearch-operator | |
| ref: ${{ env.BASE_BRANCH }} | |
| token: ${{ secrets.PAT }} | |
| submodules: true | |
| path: target-repo | |
| - name: Get reviewers | |
| id: get-reviewers | |
| working-directory: target-repo | |
| run: | | |
| REVIEWERS="" | |
| if [[ -f .github/CODEOWNERS ]]; then | |
| REVIEWERS=$(grep "${SUBMODULE_PATH}" .github/CODEOWNERS \ | |
| | awk '{for(i=2;i<=NF;i++) print substr($i,2)}' \ | |
| | paste -sd "," -) | |
| fi | |
| echo "REVIEWERS=${REVIEWERS}" >> "$GITHUB_OUTPUT" | |
| - name: Configure git signing | |
| working-directory: target-repo | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.CI_COMMITS_SSH_SIGNING_KEY }}" > ~/.ssh/ssh-key | |
| chmod 600 ~/.ssh/ssh-key | |
| git config --global user.name "canonical-data-platform-bot" | |
| git config --global user.email "canonical-data-platform-bot@canonical.com" | |
| git config --global gpg.format ssh | |
| git config --global user.signingkey ~/.ssh/ssh-key | |
| git config --global commit.gpgsign true | |
| - name: Update submodule to latest commit | |
| working-directory: target-repo | |
| run: | | |
| cd "${SUBMODULE_PATH}" | |
| git fetch --depth=1 origin ${{ github.sha }} | |
| git checkout ${{ github.sha }} | |
| cd ../.. | |
| git add "${SUBMODULE_PATH}" | |
| - name: Commit changes | |
| working-directory: target-repo | |
| run: | | |
| if git ls-remote --exit-code --heads origin "${PR_BRANCH}" >/dev/null 2>&1; then | |
| echo "ERROR: Branch '${PR_BRANCH}' already exists on remote. Refusing to overwrite it." | |
| exit 1 | |
| fi | |
| git checkout -b "${PR_BRANCH}" | |
| git commit -m "chore: Update OpenSearch Dashboards docs submodule to ${{ github.sha }}" | |
| - name: Push branch | |
| working-directory: target-repo | |
| run: | | |
| git push origin "${PR_BRANCH}" | |
| - name: Open Pull Request | |
| working-directory: target-repo | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT }} | |
| run: | | |
| BODY="Automated update of the OpenSearch Dashboards docs submodule to commit [\`${{ github.sha }}\`](https://github.com/canonical/opensearch-dashboards-operator/commit/${{ github.sha }})." | |
| REVIEWER_ARGS=() | |
| if [[ -n "${{ steps.get-reviewers.outputs.REVIEWERS }}" ]]; then | |
| REVIEWER_ARGS=(--reviewer "${{ steps.get-reviewers.outputs.REVIEWERS }}") | |
| fi | |
| PR_URL=$(gh pr create \ | |
| --title "chore: Update OpenSearch Dashboards docs submodule" \ | |
| --body "${BODY}" \ | |
| --base "${{ env.BASE_BRANCH }}" \ | |
| --head "${PR_BRANCH}" \ | |
| "${REVIEWER_ARGS[@]}" | |
| ) | |
| echo "- ${PR_URL}" >> "$GITHUB_STEP_SUMMARY" |