Fresh to vercel PR deployment #71
This file contains 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: Fresh to vercel PR deployment | |
on: | |
workflow_run: | |
workflows: [Fresh to vercel PR] | |
types: | |
- completed | |
jobs: | |
createExampleAndDeployToArtifacts: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download hugo build | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "hugo-output" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/hugo-output.zip', Buffer.from(download.data)); | |
- run: unzip hugo-output.zip -d hugo-output | |
- name: Download alias-domain | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "alias-domain" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/alias-domain.zip', Buffer.from(download.data)); | |
- run: unzip alias-domain.zip | |
- name: Extract alias-domain | |
id: extract-alias-domain | |
run: | | |
aliasDomain=`cat alias-domain` | |
echo "ALIAS_DOMAIN=$aliasDomain" >> $GITHUB_OUTPUT | |
- name: Deploy to Vercel on PR | |
uses: amondnet/vercel-action@v25 | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} | |
vercel-project-name: hugo-fresh | |
alias-domains: ${{ steps.extract-alias-domain.outputs.ALIAS_DOMAIN }} | |
working-directory: ./hugo-output |