Skip to content

Commit dd3ebff

Browse files
authored
Merge branch 'main' into golden
2 parents 49a3759 + b96e93b commit dd3ebff

File tree

133 files changed

+3243
-767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+3243
-767
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# .github/actions/set-commit-status/action.yml
2+
name: 'Set Commit Status'
3+
description: 'Sets the commit status for a given SHA'
4+
inputs:
5+
sha:
6+
description: 'The commit SHA to update the status for'
7+
required: true
8+
status:
9+
description: 'The status to set (pending, success, failure, error)'
10+
default: ${{ job.status }}
11+
context:
12+
description: 'The context for the status check'
13+
default: '${{ github.workflow }} / ${{ github.job }} (${{ github.event.workflow_run.event }})'
14+
token:
15+
description: 'GitHub token'
16+
default: ${{ github.token }}
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Set commit status
21+
uses: myrotvorets/set-commit-status-action@v2.0.1
22+
with:
23+
sha: ${{ inputs.sha }}
24+
token: ${{ inputs.token }}
25+
status: ${{ inputs.status }}
26+
context: ${{ inputs.context }}
27+
description: ${{ inputs.status }}

.github/workflows/build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
name: Build
2+
23
on:
34
push:
45
branches:
5-
- 'master'
6+
- main
67
pull_request:
78

89
jobs:
9-
test:
10+
build:
1011
runs-on: ubuntu-latest
1112

1213
steps:
1314
- name: Checkout repository
14-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1516
with:
1617
fetch-depth: 0
1718
submodules: recursive
1819
- name: Set up Python
19-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v5.2.0
2021
with:
2122
python-version: '3.8'
2223
- name: Install mkdocs-material
@@ -29,13 +30,14 @@ jobs:
2930
key: test-${{ github.event_name }}-github-users-v0.1
3031
- name: Build pages
3132
env:
32-
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ secrets.PAT_API_KEY }}
33-
MKDOCS_ENABLE_GIT_REVISION_DATE: ${{ secrets.PAT_API_KEY && 'True' || 'False' }}
34-
MKDOCS_ENABLE_GIT_COMMITTERS: ${{ secrets.PAT_API_KEY && 'True' || 'False' }}
33+
MKDOCS_GIT_COMMITTERS_BRANCH: ${{ github.ref_name }}
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' }}
3537
run: |
3638
mkdocs build --strict
37-
- name: Upload build pages as artifact
38-
uses: actions/upload-artifact@v2
39+
- name: Upload pages as an artifact
40+
uses: actions/upload-artifact@v4
3941
with:
40-
name: page-build
42+
name: ${{ github.event.number || 'main' }}
4143
path: public/

.github/workflows/delete-preview.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Delete PR Preview
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
jobs:
8+
delete_pr_preview:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout gh-pages branch
12+
uses: actions/checkout@v4
13+
with:
14+
ref: gh-pages
15+
16+
- name: Configure Git identity
17+
run: |
18+
git config --global user.name "github-actions[bot]"
19+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
20+
21+
- name: Delete PR directory
22+
run: |
23+
PR_DIR=${{ github.event.pull_request.number }}
24+
git rm -r --ignore-unmatch "${PR_DIR}/" || echo "Directory not found"
25+
git commit -m "Delete preview for #${{ github.event.pull_request.number }}"
26+
git push origin gh-pages

.github/workflows/deploy-cloud-function.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name: Deploy Cloud Function
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77

88
jobs:
99
deploy_cloud_function:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

1515
- uses: dorny/paths-filter@v2
1616
id: changes
@@ -20,7 +20,7 @@ jobs:
2020
- 'preview/**'
2121
2222
- id: 'auth'
23-
uses: 'google-github-actions/auth@v0'
23+
uses: 'google-github-actions/auth@v2.1.6'
2424
with:
2525
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
2626

.github/workflows/deploy-prod.yml

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,96 @@ name: Deploy
22

33
on:
44
workflow_run:
5-
# `workflow_run` events have access to secrets
65
workflows: [Build]
76
types:
87
- completed
98

109
jobs:
1110
deploy_live_website:
1211
runs-on: ubuntu-latest
13-
if: >
14-
${{ github.event.workflow_run.event == 'pull_request' &&
15-
github.event.workflow_run.conclusion == 'success' }}
12+
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
1613
steps:
17-
- name: "Get PR information"
18-
uses: potiuk/get-workflow-origin@751d47254ef9e8b5eef955e24e79305233702781
19-
id: source-run-info
20-
with:
21-
token: ${{ secrets.GITHUB_TOKEN }}
22-
sourceRunId: ${{ github.event.workflow_run.id }}
23-
2414
- name: Checkout repository
25-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
2616

27-
- name: 'Download artifact'
28-
uses: actions/github-script@v6
17+
- name: Attach run to the commit
18+
uses: ./.github/actions/set-commit-status
2919
with:
30-
script: |
31-
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
32-
owner: context.repo.owner,
33-
repo: context.repo.repo,
34-
run_id: context.payload.workflow_run.id,
35-
});
36-
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
37-
return artifact.name == "page-build"
38-
})[0];
39-
let download = await github.rest.actions.downloadArtifact({
40-
owner: context.repo.owner,
41-
repo: context.repo.repo,
42-
artifact_id: matchArtifact.id,
43-
archive_format: 'zip',
44-
});
45-
let fs = require('fs');
46-
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/page-build.zip`, Buffer.from(download.data));
20+
sha: ${{ github.event.workflow_run.head_sha }}
21+
status: pending
4722

48-
- run: |
49-
unzip page-build.zip -d public
23+
- name: Download pages
24+
uses: actions/download-artifact@v4
25+
with:
26+
run-id: ${{ github.event.workflow_run.id }}
27+
github-token: ${{ github.token }}
28+
merge-multiple: true
29+
path: public
5030

5131
- name: change URLs for large files
52-
if: ${{ steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch == 'master'}}
5332
shell: bash
54-
run: |
55-
sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
33+
run: sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
5634

57-
- id: 'auth'
58-
if: ${{ steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch == 'master'}}
59-
uses: 'google-github-actions/auth@v0'
35+
- id: auth
36+
uses: google-github-actions/auth@v2.1.6
6037
with:
6138
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
6239

63-
- uses: 'google-github-actions/upload-cloud-storage@v1'
64-
if: ${{ steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch == 'master'}}
40+
- uses: google-github-actions/upload-cloud-storage@v2.2.0
6541
with:
66-
path: 'public/search/search_index.json'
67-
destination: 'cp-algorithms'
42+
path: public/search/search_index.json
43+
destination: cp-algorithms
6844

6945
- uses: FirebaseExtended/action-hosting-deploy@v0
7046
id: firebase-deploy
71-
if: env.FIREBASE_SERVICE_ACCOUNT
72-
env:
73-
PREVIEW_NAME: "preview-${{ steps.source-run-info.outputs.pullRequestNumber }}"
74-
LIVE_NAME: "live"
75-
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
7647
with:
77-
repoToken: "${{ secrets.GITHUB_TOKEN }}"
78-
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
48+
repoToken: ${{ github.token }}
49+
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
7950
projectId: cp-algorithms
80-
channelId: ${{ steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch == 'master' && env.LIVE_NAME || env.PREVIEW_NAME }}
51+
channelId: live
8152

82-
- name: comment URL to PR
83-
if: ${{ steps.source-run-info.outputs.sourceEvent == 'pull_request' }}
84-
uses: actions/github-script@v6
53+
- name: Set final commit status
54+
uses: ./.github/actions/set-commit-status
55+
if: always()
8556
with:
86-
script: |
87-
const body = `Visit the preview URL for this PR (for commit ${{ steps.source-run-info.outputs.sourceHeadSha }}):
57+
sha: ${{ github.event.workflow_run.head_sha }}
8858

89-
${{ steps.firebase-deploy.outputs.details_url }}
59+
deploy_github_pages:
60+
runs-on: ubuntu-latest
61+
if: github.event.workflow_run.conclusion == 'success'
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
9065

91-
(expires ${{ steps.firebase-deploy.outputs.expire_time }})`;
66+
- name: Attach run to the commit
67+
uses: ./.github/actions/set-commit-status
68+
with:
69+
sha: ${{ github.event.workflow_run.head_sha }}
70+
status: pending
9271

93-
github.rest.issues.createComment({
94-
issue_number: ${{ steps.source-run-info.outputs.pullRequestNumber }},
95-
owner: context.repo.owner,
96-
repo: context.repo.repo,
97-
body: body
98-
})
72+
- name: Download pages
73+
uses: actions/download-artifact@v4
74+
with:
75+
run-id: ${{ github.event.workflow_run.id }}
76+
github-token: ${{ github.token }}
77+
path: public
78+
79+
- name: Get PR number from artifact
80+
id: get-pr-number
81+
run: echo "pr_number=$(ls public)" >> $GITHUB_OUTPUT
82+
83+
- name: Deploy to gh-pages
84+
uses: peaceiris/actions-gh-pages@v4
85+
with:
86+
github_token: ${{ github.token }}
87+
user_name: github-actions[bot]
88+
user_email: github-actions[bot]@users.noreply.github.com
89+
publish_dir: public/${{ steps.get-pr-number.outputs.pr_number }}
90+
destination_dir: ${{ steps.get-pr-number.outputs.pr_number }}
91+
full_commit_message: "Preview for ${{ steps.get-pr-number.outputs.pr_number != 'main' && '#' || '' }}${{ steps.get-pr-number.outputs.pr_number }} (${{ github.event.workflow_run.head_sha }}) at https://gh.cp-algorithms.com/${{ steps.get-pr-number.outputs.pr_number }}/"
92+
93+
- name: Set final commit status
94+
uses: ./.github/actions/set-commit-status
95+
if: always()
96+
with:
97+
sha: ${{ github.event.workflow_run.head_sha }}

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Test
22
on:
33
push:
44
branches:
5-
- 'master'
5+
- 'main'
66
pull_request:
77

88
jobs:
@@ -11,9 +11,9 @@ jobs:
1111

1212
steps:
1313
- name: Checkout repository
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
- name: Set up Python
16-
uses: actions/setup-python@v2
16+
uses: actions/setup-python@v5.2.0
1717
with:
1818
python-version: '3.8'
1919
- name: Set up C++

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy