From 75c9c8f2468faf8a956e9754ac5f6b9b7b5a3494 Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Wed, 12 Jun 2024 23:07:57 +0000 Subject: [PATCH] Add simple workflow Change-Id: Iae5adac03d980d5f0dc7ad704502cfae829c7bd6 --- .github/actions/pre_commit/action.yaml | 7 ++++ .github/workflows/documentation.yaml | 51 ++++++++++++++++++++++++++ .github/workflows/lint.yaml | 8 ---- 3 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/documentation.yaml diff --git a/.github/actions/pre_commit/action.yaml b/.github/actions/pre_commit/action.yaml index 63402a000390..7e73f2d49e8e 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: diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 000000000000..330a7bea7bc0 --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,51 @@ +name: Cobalt Documentation + +on: + pull_request_target: + types: + - closed + +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 cobalt/site/docs + shell: bash + - name: Run pre-commit + uses: ./.github/actions/pre_commit + with: + base_ref: ${{ github.event.pull_request.base.sha || github.event.before }} + - name: Create Pull Request + 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 }} + reviewers: ${{ github.event.pull_request.user.login }} + committer: GitHub Release Automation + title: "Documentation changes 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 }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b6a1f84338c0..f93342d8aa73 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -43,14 +43,6 @@ jobs: with: fetch-depth: 0 persist-credentials: false - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.8' - - name: Install Pip Packages - run: pip install --require-hashes --no-deps -r ${GITHUB_WORKSPACE}/precommit_hooks/requirements.txt - - name: Download Resources - run: python ${GITHUB_WORKSPACE}/download_resources.py - name: Run pre-commit uses: ./.github/actions/pre_commit with: