Skip to content

Deploy Canary

Deploy Canary #421

Workflow file for this run

name: Deploy Canary
on:
workflow_run:
workflows: [ci]
types: [completed]
branches: [main]
jobs:
deploy-canary:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: Canary
url: https://canary.renda.studio/
steps:
- name: Download build artifact
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
with:
script: |
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
artifacts = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "build"
});
if (artifacts.length <= 0) {
throw new Error("No artifact found.");
}
const matchArtifact = artifacts[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/artifact.zip', Buffer.from(download.data));
- name: Unzip artifact
run: unzip artifact.zip
- name: Deploy files
env:
CANARY_DEPLOY_TOKEN: ${{ secrets.CANARY_DEPLOY_TOKEN }}
COMMIT_SHA: ${{ github.sha }}
run: |
curl -X POST --fail -H "Authorization: DeployToken $CANARY_DEPLOY_TOKEN" -H "Content-Type: application/x-tar" --data-binary @build_files.tar "https://deploy.renda.studio/canary?commit=$COMMIT_SHA"