forked from cp-algorithms/cp-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 3.21 KB
/
deploy-prod.yml
File metadata and controls
97 lines (82 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Deploy
on:
workflow_run:
workflows: [Build]
types:
- completed
jobs:
deploy_live_website:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Attach run to the commit
uses: ./.github/actions/set-commit-status
with:
sha: ${{ github.event.workflow_run.head_sha }}
status: pending
- name: Download pages
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
merge-multiple: true
path: public
- name: change URLs for large files
shell: bash
run: sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
- id: auth
uses: google-github-actions/auth@v2.1.6
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- uses: google-github-actions/upload-cloud-storage@v2.2.0
with:
path: public/search/search_index.json
destination: cp-algorithms
- uses: FirebaseExtended/action-hosting-deploy@v0
id: firebase-deploy
with:
repoToken: ${{ github.token }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
projectId: cp-algorithms
channelId: live
- name: Set final commit status
uses: ./.github/actions/set-commit-status
if: always()
with:
sha: ${{ github.event.workflow_run.head_sha }}
deploy_github_pages:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Attach run to the commit
uses: ./.github/actions/set-commit-status
with:
sha: ${{ github.event.workflow_run.head_sha }}
status: pending
- name: Download pages
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
path: public
- name: Get PR number from artifact
id: get-pr-number
run: echo "pr_number=$(ls public)" >> $GITHUB_OUTPUT
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ github.token }}
user_name: github-actions[bot]
user_email: github-actions[bot]@users.noreply.github.com
publish_dir: public/${{ steps.get-pr-number.outputs.pr_number }}
destination_dir: ${{ steps.get-pr-number.outputs.pr_number }}
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 }}/"
- name: Set final commit status
uses: ./.github/actions/set-commit-status
if: always()
with:
sha: ${{ github.event.workflow_run.head_sha }}