Skip to content

Deploying

Deploying #55

Workflow file for this run

name: deploy
run-name: Deploying
concurrency:
group: '${{ github.workflow }}'
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/github-script@v7
with:
script: |
const { data } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'test-and-build.yml',
status: 'completed',
});
const successfulRunId = data.workflow_runs.find(run => run.conclusion === 'success').id;
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: successfulRunId,
});
const artifactFrontendId = allArtifacts.data.artifacts.find((artifact) => artifact.name == "frontend-dist").id;
const artifactBackendId = allArtifacts.data.artifacts.find((artifact) => artifact.name == "backend-dist").id;
const downloadFrontend = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifactFrontendId,
archive_format: 'zip',
});
const downloadBackend = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifactBackendId,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/frontend.zip`, Buffer.from(downloadFrontend.data));
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/backend.zip`, Buffer.from(downloadBackend.data));
- name: Unzip artifacts
run: |
unzip frontend.zip -d frontend/dist
unzip backend.zip -d backend/dist
# Example of deploying to Cloudflare
# - name: Deploy 'frontend/dist' to Cloudflare Pages
# uses: cloudflare/pages-action@v1
# with:
# apiToken: your-token
# accountId: your-account-id
# projectName: your-project-name
# workingDirectory: frontend
# directory: dist
# branch: main