Skip to content

Deploy

Deploy #1284

Workflow file for this run

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 }}