From d6c39f57ea4b2519e2b5e5e9b71cc8102df83294 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 11 Jan 2025 17:38:46 +0900 Subject: [PATCH] =?UTF-8?q?chore(PR-build):=20peaceiris/actions-gh-pages@v?= =?UTF-8?q?4=20=E3=82=92=E7=94=A8=E3=81=84=E3=81=A6=E3=82=A2=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 23 ++++++++++++++++++----- .github/workflows/check.yml | 4 ++-- .github/workflows/script/build.sh | 11 ----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a02b751ec..9b88b507e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,6 @@ on: default: '' required: false type: string - secrets: - CPPREFJP_GITHUB_IO_SECRETS: - description: "ssh 秘密鍵の内容" - required: true push: branches: - master @@ -26,6 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Register SSH key + if: !startsWith(inputs.arguments, '--pull ') env: CPPREFJP_GITHUB_IO_SECRETS: ${{ secrets.CPPREFJP_GITHUB_IO_SECRETS }} run: | @@ -50,7 +47,8 @@ jobs: working-directory: site_generator/kunai # cpprefjp.github.io - - uses: actions/checkout@v4 + - if: !startsWith(inputs.arguments, '--pull ') + uses: actions/checkout@v4 with: repository: cpprefjp/cpprefjp.github.io path: site_generator/cpprefjp/cpprefjp.github.io @@ -77,11 +75,26 @@ jobs: python-version: 3.11 # 3.12でUndefined symbolエラーがでた + # PR build 用 (現在の gh-pages の状態を取得) + - if: startsWith(inputs.arguments, '--pull ') + uses: actions/checkout@v4 + with: + repository: cpprefjp/site + path: site_generator/cpprefjp/cpprefjp.github.io-site + ref: gh-pages + # あとはスクリプトで頑張る - name: Run script build.sh run: ./cpprefjp/site/.github/workflows/script/build.sh ${{ inputs.arguments }} working-directory: site_generator + # PR build 用 (更新後の状態を upload) + - if: startsWith(inputs.arguments, '--pull ') + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./site_generator/cpprefjp/cpprefjp.github.io-site + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f85f09d6e..a265273cd 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -131,5 +131,5 @@ jobs: uses: ./.github/workflows/build.yml with: arguments: --pull ${{ github.event.number }} - secrets: - CPPREFJP_GITHUB_IO_SECRETS: ${{ secrets.CPPREFJP_GITHUB_IO_SECRETS }} + concurrency: + group: cpprefjp.gh-pages.lock diff --git a/.github/workflows/script/build.sh b/.github/workflows/script/build.sh index 43170d841..504136be7 100755 --- a/.github/workflows/script/build.sh +++ b/.github/workflows/script/build.sh @@ -52,21 +52,10 @@ elif [[ $1 == --pull ]]; then exit 2 fi - target_repository=git@github.com:cpprefjp/site.git working_directory=cpprefjp/cpprefjp.github.io-site - - git remote add origin2 "$target_repository" - git clone --depth=1 git@github.com:cpprefjp/site.git -b gh-pages "$working_directory" rm -rf "$working_directory/pull/$2" mkdir -p "$working_directory/pull/$2" cp -r cpprefjp/cpprefjp.github.io/* "$working_directory/pull/$2"/ - pushd "$working_directory" - git add ./ --all - git config --global user.email "shigemasa7watanabe+cpprefjp@gmail.com" - git config --global user.name "cpprefjp-autoupdate" - git commit -a -m "update automatically" - git push origin2 gh-pages - popd else printf '%s\n' "build.sh: コマンドライン引数が認識できません: $1" >&2