From 09eaa0d732a99de41e0f4b78ac26a85bb379cfdd Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Thu, 13 Jun 2024 15:52:31 -0700 Subject: [PATCH 1/5] Create documentation.yaml --- .github/workflows/documentation.yaml | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/documentation.yaml diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 0000000000000..bca68bf977be0 --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,73 @@ +name: Cobalt Documentation + +on: + pull_request: + push: + branches: + - main + - 25.lts.1+ + +concurrency: + group: '${{ github.workflow }}-${{ github.event_name }} @ ${{ github.event.pull_request.number || github.sha }}' + cancel-in-progress: true + +permissions: {} + +jobs: + developer-docs: + name: Generate Docs + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: kaidokert/checkout@v3.5.999 + with: + ref: ${{ github.base_ref }} + fetch-depth: 0 + persist-credentials: false + - name: Docker Build + run: docker build -t docsite --build-arg UID=$(id -u) --build-arg GID=$(id -g) cobalt/site/docker + shell: bash + - name: Docker Run + run: docker run --mount type=bind,source=$(pwd),target=/code docsite + shell: bash + - name: Stage files for pre-commit + run: git add -A + shell: bash + + # TODO: REMOVE + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + - name: Install Pip Packages + shell: bash + run: pip install --require-hashes --no-deps -r ${GITHUB_WORKSPACE}/precommit_hooks/requirements.txt + + + + - name: Run pre-commit + uses: ./.github/actions/pre_commit + with: + base_ref: ${{ github.event.pull_request.base.sha || github.event.before }} + + - name: Git diff (DEBUG) + run: | + git reset + git diff + shell: bash + + - name: Create Pull Request + id: create-pr + continue-on-error: true + uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3 + with: + # token: ${{ secrets.CHERRY_PICK_TOKEN }} + base: ${{ github.base_ref }} + branch: doc-${{ github.event.pull_request.number }} + committer: GitHub Release Automation + title: "Documentation change for #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" + body: | + Refer to the original PR: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} + + ${{ github.event.pull_request.body }} From bf85732316cdfd2bd42233229acaab2f1c8e0507 Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Thu, 13 Jun 2024 15:57:29 -0700 Subject: [PATCH 2/5] Add secret --- .github/workflows/documentation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index bca68bf977be0..99765ef8f073f 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -62,7 +62,7 @@ jobs: continue-on-error: true uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3 with: - # token: ${{ secrets.CHERRY_PICK_TOKEN }} + token: ${{ secrets.CHERRY_PICK_TOKEN }} base: ${{ github.base_ref }} branch: doc-${{ github.event.pull_request.number }} committer: GitHub Release Automation From 3096ca85673b99c7dd96ed6a4c3a54df0b8328a2 Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Thu, 13 Jun 2024 17:13:03 -0700 Subject: [PATCH 3/5] Update documentation.yaml --- .github/workflows/documentation.yaml | 73 ++++++++++++++++------------ 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 99765ef8f073f..738aa81754c17 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -1,11 +1,10 @@ name: Cobalt Documentation on: - pull_request: - push: - branches: - - main - - 25.lts.1+ + pull_request_target: + types: + - closed + workflow_dispatch: concurrency: group: '${{ github.workflow }}-${{ github.event_name }} @ ${{ github.event.pull_request.number || github.sha }}' @@ -19,6 +18,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: + - name: DEBUG + run: echo ${{ github }} + shell: bash - name: Checkout uses: kaidokert/checkout@v3.5.999 with: @@ -31,43 +33,52 @@ jobs: - name: Docker Run run: docker run --mount type=bind,source=$(pwd),target=/code docsite shell: bash - - name: Stage files for pre-commit - run: git add -A - shell: bash - - # TODO: REMOVE - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.8' - - name: Install Pip Packages + - name: Stage docs for pre-commit + run: git add -A cobalt/site/docs shell: bash - run: pip install --require-hashes --no-deps -r ${GITHUB_WORKSPACE}/precommit_hooks/requirements.txt - - - - name: Run pre-commit uses: ./.github/actions/pre_commit with: base_ref: ${{ github.event.pull_request.base.sha || github.event.before }} + - name: Set env variables (PR) + if: github.event_name == 'pull_request' + run: | + branch="doc-${{ github.event.pull_request.number }}" + echo "BRANCH=${branch}" >> ${GITHUB_ENV} - - name: Git diff (DEBUG) + reviewers="${{ github.event.pull_request.user.login }}" + echo "REVIEWERS=${reviewers}" >> ${GITHUB_ENV} + + title="Documentation changes for #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" + echo "TITLE=${title}" >> ${GITHUB_ENV} + + body=$(cat <<-EOF + Refer to the original PR: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} + + ${{ github.event.pull_request.body }} + EOF + ) + echo "BODY=${body}" >> ${GITHUB_ENV} + - name: Set env variables (postsubmit) + if: github.event_name == 'pull_request' run: | - git reset - git diff - shell: bash + branch="doc-${{ github.run_id }}" + echo "BRANCH=${branch}" >> ${GITHUB_ENV} + reviewers="${{ github.actor }}" + echo "REVIEWERS=${reviewers}" >> ${GITHUB_ENV} + + title="Documentation changes for ${{ github.base_ref }}" + echo "TITLE=${title}" >> ${GITHUB_ENV} + + echo "BODY=" >> ${GITHUB_ENV} - name: Create Pull Request - id: create-pr - continue-on-error: true uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3 with: token: ${{ secrets.CHERRY_PICK_TOKEN }} base: ${{ github.base_ref }} - branch: doc-${{ github.event.pull_request.number }} + branch: ${{ env.BRANCH }} + reviewers: ${{ env.REVIEWERS }} committer: GitHub Release Automation - title: "Documentation change for #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" - body: | - Refer to the original PR: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} - - ${{ github.event.pull_request.body }} + title: ${{ env.TITLE }} + body: ${{ env.BODY }} From 5d9dafc1ec5360b365c48adbf7566a43a955d466 Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Thu, 13 Jun 2024 17:13:49 -0700 Subject: [PATCH 4/5] Install python in pre-commit action (#670) --- .github/actions/pre_commit/action.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/actions/pre_commit/action.yaml b/.github/actions/pre_commit/action.yaml index 63402a000390e..7e73f2d49e8ec 100644 --- a/.github/actions/pre_commit/action.yaml +++ b/.github/actions/pre_commit/action.yaml @@ -7,6 +7,13 @@ inputs: runs: using: "composite" steps: + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + - name: Install Pip Packages + shell: bash + run: pip install --require-hashes --no-deps -r ${GITHUB_WORKSPACE}/precommit_hooks/requirements.txt - run: pre-commit run --show-diff-on-failure --color=always --from-ref ${{ inputs.base_ref }} --to-ref HEAD shell: bash env: From b020046eb36522366d3ee8672e16489a9837526c Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Thu, 13 Jun 2024 17:16:02 -0700 Subject: [PATCH 5/5] Update documentation.yaml --- .github/workflows/documentation.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 738aa81754c17..aca311892cbb6 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -14,6 +14,7 @@ permissions: {} jobs: developer-docs: + if: github.actor != 'cobalt-github-releaser-bot' name: Generate Docs runs-on: ubuntu-latest timeout-minutes: 15