Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2c09148

Browse files
authored
Merge branch 'main' into master
2 parents9a8fb58 +e357737 commit2c09148

File tree

2 files changed

+50
-88
lines changed

2 files changed

+50
-88
lines changed

‎.github/workflows/build.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name:Build
22

3-
on:
4-
workflow_call:
3+
on:
4+
push:
5+
branches:
6+
-main
7+
pull_request:
58

69
jobs:
710
build:
@@ -28,13 +31,13 @@ jobs:
2831
-name:Build pages
2932
env:
3033
MKDOCS_GIT_COMMITTERS_BRANCH:${{ github.ref_name }}
31-
MKDOCS_GIT_COMMITTERS_APIKEY:${{secrets.GITHUB_TOKEN }}
32-
MKDOCS_ENABLE_GIT_REVISION_DATE:${{secrets.GITHUB_TOKEN && 'True' || 'False' }}
33-
MKDOCS_ENABLE_GIT_COMMITTERS:${{secrets.GITHUB_TOKEN && 'True' || 'False' }}
34+
MKDOCS_GIT_COMMITTERS_APIKEY:${{github.token }}
35+
MKDOCS_ENABLE_GIT_REVISION_DATE:${{github.token && 'True' || 'False' }}
36+
MKDOCS_ENABLE_GIT_COMMITTERS:${{github.token && 'True' || 'False' }}
3437
run:|
3538
mkdocs build --strict
36-
-name:Uploadbuildpages as artifact
39+
-name:Upload pages as an artifact
3740
uses:actions/upload-artifact@v4
3841
with:
39-
name:page-build
42+
name:${{ github.event.number || 'main' }}
4043
path:public/

‎.github/workflows/deploy-prod.yml

Lines changed: 40 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,86 @@
11
name:Deploy
22

3-
on:
4-
push:
5-
branches:
6-
-main
7-
pull_request:
3+
on:
4+
workflow_run:
5+
workflows:[Build]
6+
types:
7+
-completed
88

99
jobs:
10-
build:
11-
uses:./.github/workflows/build.yml
12-
secrets:inherit
13-
1410
deploy_live_website:
1511
runs-on:ubuntu-latest
16-
needs:build
17-
if:github.event_name == 'push'
12+
if:github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
1813
steps:
19-
-name:Checkout
20-
uses:actions/checkout@v4
14+
-name:Checkout repository
15+
uses:actions/checkout@v3
2116

2217
-name:Download pages
2318
uses:actions/download-artifact@v4
2419
with:
25-
name:page-build
20+
run-id:${{ github.event.workflow_run.id }}
21+
github-token:${{ github.token }}
22+
merge-multiple:true
2623
path:public
2724

28-
-name:Get PR information
29-
uses:potiuk/get-workflow-origin@751d47254ef9e8b5eef955e24e79305233702781
30-
id:source-run-info
31-
with:
32-
token:${{ secrets.GITHUB_TOKEN }}
33-
sourceRunId:${{ github.event.workflow_run.id }}
34-
3525
-name:change URLs for large files
3626
shell:bash
37-
run:|
38-
sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
27+
run:sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
3928

40-
-id:'auth'
41-
uses:'google-github-actions/auth@v2.1.6'
29+
-id:auth
30+
uses:google-github-actions/auth@v2.1.6
4231
with:
4332
credentials_json:'${{ secrets.GCP_CREDENTIALS }}'
4433

45-
-uses:'google-github-actions/upload-cloud-storage@v1'
34+
-uses:google-github-actions/upload-cloud-storage@v1
4635
with:
47-
path:'public/search/search_index.json'
48-
destination:'cp-algorithms'
36+
path:public/search/search_index.json
37+
destination:cp-algorithms
4938

5039
-uses:FirebaseExtended/action-hosting-deploy@v0
5140
id:firebase-deploy
52-
if:env.FIREBASE_SERVICE_ACCOUNT
53-
env:
54-
LIVE_NAME:"live"
55-
FIREBASE_SERVICE_ACCOUNT:${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
5641
with:
57-
repoToken:"${{secrets.GITHUB_TOKEN }}"
58-
firebaseServiceAccount:"${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
42+
repoToken:${{github.token }}
43+
firebaseServiceAccount:${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
5944
projectId:cp-algorithms
60-
channelId:${{ env.LIVE_NAME }}
45+
channelId:live
6146

6247
deploy_github_pages:
6348
runs-on:ubuntu-latest
64-
needs:build
49+
if:github.event.workflow_run.conclusion == 'success'
6550
steps:
6651
-name:Checkout repository
6752
uses:actions/checkout@v3
6853

69-
-name:Downloadartifact
54+
-name:Downloadpages
7055
uses:actions/download-artifact@v4
7156
with:
72-
name:page-build
57+
run-id:${{ github.event.workflow_run.id }}
58+
github-token:${{ github.token }}
7359
path:public
7460

61+
-name:Get PR number from artifact
62+
id:get-pr-number
63+
run:echo "pr_number=$(ls public)" >> $GITHUB_OUTPUT
64+
7565
-name:Configure git
7666
run:|
7767
git config --global user.name "github-actions[bot]"
7868
git config --global user.email "github-actions[bot]@users.noreply.github.com"
79-
69+
8070
-name:Deploy to gh-pages
8171
uses:peaceiris/actions-gh-pages@v3
8272
with:
83-
github_token:${{secrets.GITHUB_TOKEN }}
84-
publish_dir:./public
73+
github_token:${{github.token }}
74+
publish_dir:public/${{ steps.get-pr-number.outputs.pr_number }}
8575
publish_branch:gh-pages
86-
destination_dir:${{github.event.pull_request.number || 'main' }}/
76+
destination_dir:${{steps.get-pr-number.outputs.pr_number }}
8777

88-
-name:Update orcreate preview comment
89-
if:github.event_name == 'pull_request'
90-
uses:actions/github-script@v6
78+
-name:Create orupdate PR comment
79+
if:steps.get-pr-number.outputs.pr_number != 'main'
80+
uses:peter-evans/create-or-update-comment@v3
9181
with:
92-
script:|
93-
const prNumber = ${{ github.event.pull_request.number }};
94-
const repo = context.repo.repo;
95-
const owner = context.repo.owner;
96-
const commitSha = context.payload.pull_request.head.sha;
97-
const baseUrl = `https://${owner}.github.io/${repo}/`;
98-
const previewUrl = `${baseUrl}${prNumber}/`;
99-
const body = `Preview the changes for PR #${prNumber} (${commitSha}) here: [${previewUrl}](${previewUrl})`;
100-
101-
// Retrieve comments for the PR to check if the comment already exists
102-
const { data:comments } = await github.rest.issues.listComments({
103-
owner:owner,
104-
repo:repo,
105-
issue_number:prNumber,
106-
});
107-
108-
// Look for an existing comment with the preview link
109-
const existingComment = comments.find(comment => comment.body.includes('Preview the changes for PR'));
110-
111-
if (existingComment) {
112-
// Update the existing comment
113-
await github.rest.issues.updateComment({
114-
owner:owner,
115-
repo:repo,
116-
comment_id:existingComment.id,
117-
body:body,
118-
});
119-
} else {
120-
// Create a new comment
121-
await github.rest.issues.createComment({
122-
issue_number:prNumber,
123-
owner:owner,
124-
repo:repo,
125-
body:body,
126-
});
127-
}
82+
token:${{ github.token }}
83+
issue-number:${{ steps.get-pr-number.outputs.pr_number }}
84+
body:'Preview the changes for PR #${{ steps.get-pr-number.outputs.pr_number }} at https://gh.cp-algorithms.com/${{ steps.get-pr-number.outputs.pr_number }}/ (current version: ${{ github.event.workflow_run.head_sha }}).'
85+
body-includes:'Preview the changes for PR'
86+
mode:replace

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp