Skip to content

Commit

Permalink
chore(PR-build): peaceiris/actions-gh-pages@v4 を用いてアップロード
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 11, 2025
1 parent 69053d1 commit d6c39f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ on:
default: ''
required: false
type: string
secrets:
CPPREFJP_GITHUB_IO_SECRETS:
description: "ssh 秘密鍵の内容"
required: true
push:
branches:
- master
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions .github/workflows/script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,10 @@ elif [[ $1 == --pull ]]; then
exit 2
fi

[email protected]:cpprefjp/site.git
working_directory=cpprefjp/cpprefjp.github.io-site

git remote add origin2 "$target_repository"
git clone --depth=1 [email protected]: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 "[email protected]"
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
Expand Down

0 comments on commit d6c39f5

Please sign in to comment.