-
Notifications
You must be signed in to change notification settings - Fork 4
add: pull request page preview #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Build | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install mdbook | ||
| uses: peaceiris/actions-mdbook@v2 | ||
| with: | ||
| mdbook-version: "latest" | ||
|
|
||
| - name: Build mdbook | ||
| run: mdbook build --dest-dir out | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shellプロパティは必須です.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
と書いてあるように見えます
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. すみません...見落としてました。 |
||
|
|
||
| - name: Cache Cargo registry and Cargo bin | ||
| id: cargo-cache | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| ~/.cargo/bin | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock','**/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Install mdbook-utils | ||
| if: steps.cargo-cache.outputs.cache-hit != 'true' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同様にshellプロパティの不足 |
||
| run: cargo install mdbook-utils | ||
|
|
||
| - name: Generate sitemap | ||
| run: mdbook-utils sitemap -o out/sitemap.xml -b https://rsdocsjp.org/ -y | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同様にshellプロパティの不足 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Deploy site to Github Pages | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-and-commit: | ||
| name: Deploy | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Build Check | ||
| uses: ./.github/workflows/build | ||
|
|
||
| - name: Move out directory | ||
| run: | | ||
| mkdir -p tmp/out | ||
| mv out tmp/out | ||
|
|
||
| - name: Checkout gh-pages | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: gh-pages | ||
|
|
||
| - name: Preserve specific directories | ||
| run: | | ||
| mkdir -p preserve | ||
| mv out/preview preserve/preview | ||
|
|
||
| - name: Adapt new build | ||
| run: | | ||
| mv -f tmp/out out | ||
| mv -f preserve/preview out/preview | ||
|
|
||
| - name: Clean | ||
| run: | | ||
| find . -type f ! -path "./.github/*" ! -path "./out/*" ! -path "./.git/*" -delete | ||
|
|
||
| - name: Commit changes to gh-pages branch | ||
| run: | | ||
| git config --global user.name "GitHub Actions" | ||
| git config --global user.email "action@github.com" | ||
| git add -N . | ||
| set +e | ||
| git diff --exit-code --quiet | ||
| if [[ $? -eq 1 ]]; then | ||
| git add . | ||
| git commit -m "Deploy to gh-pages: ${{ github.sha }}" | ||
| git push origin gh-pages | ||
| fi |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||
| name: Deploy site to Github Pages | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: ["gh-pages"] | ||||||
| workflow_dispatch: | ||||||
|
|
||||||
| permissions: | ||||||
| contents: read | ||||||
| pages: write | ||||||
| id-token: write | ||||||
|
|
||||||
| concurrency: | ||||||
| group: "pages" | ||||||
| cancel-in-progress: true | ||||||
|
|
||||||
| jobs: | ||||||
| deploy: | ||||||
| name: Deploy | ||||||
|
|
||||||
| environment: | ||||||
| name: github-pages | ||||||
| url: ${{ steps.deployment.outputs.page_url }} | ||||||
|
|
||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 一貫性のためにpreview.ymlと同様にCheckout gh-pagesにしてほしいです.
Suggested change
|
||||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| ref: gh-pages | ||||||
|
|
||||||
| - name: Upload artifact | ||||||
| uses: actions/upload-pages-artifact@v3 | ||||||
| with: | ||||||
| path: ./out | ||||||
|
|
||||||
| - name: Deploy to GitHub Pages | ||||||
| id: deployment | ||||||
| uses: actions/deploy-pages@v4 | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||
| name: Deploy PR previews | ||||||
|
|
||||||
| on: | ||||||
| pull_request: | ||||||
| types: [opened, synchronize, reopened, closed] | ||||||
|
|
||||||
| permissions: | ||||||
| contents: write | ||||||
| pull-requests: write | ||||||
|
|
||||||
| concurrency: | ||||||
| group: pr-${{ github.event.pull_request.number }} | ||||||
| cancel-in-progress: true | ||||||
|
|
||||||
| env: | ||||||
| PAGE_DIR: pr-preview-${{ github.event.pull_request.number }} | ||||||
|
|
||||||
| jobs: | ||||||
| build-and-commit: | ||||||
| if: github.event.action != 'closed' | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout repo | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Build Check | ||||||
| uses: ./.github/workflows/build | ||||||
|
|
||||||
| - name: Move out directory | ||||||
| run: | | ||||||
| mkdir -p tmp/out | ||||||
| mv -f out tmp/out | ||||||
|
|
||||||
| - name: Checkout gh-pages | ||||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| ref: gh-pages | ||||||
|
|
||||||
| - name: Commit changes to gh-pages branch | ||||||
| run: | | ||||||
| git config --global user.name "GitHub Actions" | ||||||
| git config --global user.email "action@github.com" | ||||||
| mkdir -p out/preview/${{ env.PAGE_DIR }} | ||||||
| mv tmp/out /out/preview/${{ env.PAGE_DIR }} | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これは絶対パスではまずいように思えます. |
||||||
| git add . | ||||||
| git commit -m "Deploy PR preview for #${{ github.event.pull_request.number }}" | ||||||
| git push origin gh-pages | ||||||
|
|
||||||
| - name: Comment PR | ||||||
| uses: actions/github-script@v7 | ||||||
| with: | ||||||
| script: | | ||||||
| github.rest.issues.createComment({ | ||||||
| issue_number: context.issue.number, | ||||||
| owner: context.repo.owner, | ||||||
| repo: context.repo.repo, | ||||||
| body: `Preview deployed to: https://${context.repo.owner}.github.io/preview/${process.env.PAGE_DIR}` | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. カスタムドメインがあるので
Suggested change
が正しいと思われます. |
||||||
| }) | ||||||
|
|
||||||
| cleanup: | ||||||
| if: github.event.action == 'closed' | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout gh-pages | ||||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| ref: gh-pages | ||||||
|
|
||||||
| - name: Remove preview directory | ||||||
| run: | | ||||||
| rm -rf ./out/preview/${{ env.PAGE_DIR }} || exit 0 | ||||||
| git config user.name github-actions | ||||||
| git config user.email github-actions@github.com | ||||||
| git add . | ||||||
| git commit -m "Remove PR preview for #${{ github.event.pull_request.number }}" && git push origin gh-pages || echo "No changes to commit" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
descriptionプロパティは必須です.
https://docs.github.com/ja/actions/reference/workflows-and-actions/metadata-syntax#description