Deploying #70
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 == "dist").id; | |
const downloadFrontend = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: artifactFrontendId, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/dist.zip`, Buffer.from(downloadFrontend.data)); | |
- name: Unzip artifacts | |
run: | | |
unzip dist.zip -d dist | |
# Example of deploying to Cloudflare | |
# - name: Deploy 'dist' to Cloudflare Pages | |
# uses: cloudflare/pages-action@v1 | |
# with: | |
# apiToken: your-token | |
# accountId: your-account-id | |
# projectName: your-project-name | |
# directory: dist | |
# branch: main |