Skip to content

Commit

Permalink
Fix vercel deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
StefMa committed Mar 3, 2023
1 parent 488276c commit 814f747
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
53 changes: 43 additions & 10 deletions .github/workflows/fresh-to-vercel-pr-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,53 @@ jobs:
uses: actions/checkout@v3

- name: Download hugo build
uses: actions/download-artifact@v3
uses: actions/[email protected]
with:
name: hugo-output
path: public/
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/download-artifact@v3
- name: Download alias-domain
uses: actions/[email protected]
with:
name: alias-domain
path: alias-domain
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/alias-domain`
aliasDomain=`cat alias-domain`
echo "ALIAS_DOMAIN=$aliasDomain" >> $GITHUB_OUTPUT
- name: Deploy to Vercel on PR
Expand All @@ -37,5 +69,6 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
alias-domains: ${{ steps.extract-alias-domain.outputs.ALIAS_DOMAIN }}"
working-directory: ./public
vercel-project-name: hugo-fresh
alias-domains: ${{ steps.extract-alias-domain.outputs.ALIAS_DOMAIN }}
working-directory: ./hugo-output
9 changes: 2 additions & 7 deletions .github/workflows/fresh-to-vercel-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ jobs:
- name: Build with Hugo on PR
working-directory: exampleSite
run: |
git clone https://github.com/StefMa/hugo-fresh themes/hugo-fresh
cd themes/hugo-fresh
git fetch origin ${{ github.ref }}:pr-branch-name
git checkout pr-branch-name
cd ../..
hugo \
--minify \
--baseURL https://hugo-fresh-${{ github.run_number }}.vercel.app
--baseURL https://hugo-fresh-${{ github.event.pull_request.head.user.login }}-${{ github.event.pull_request.head.ref }}.vercel.app
- name: Save hugo as artifact
uses: actions/upload-artifact@v3
Expand All @@ -37,7 +32,7 @@ jobs:
- name: Save alias domain
run: |
mkdir -p ./alias-domain
echo https://hugo-fresh-${{ github.run_number }}.vercel.app > ./alias-domain/alias-domain
echo hugo-fresh-${{ github.event.pull_request.head.user.login }}-${{ github.event.pull_request.head.ref }}.vercel.app > ./alias-domain/alias-domain
- name: Save alias domain as artifact
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fresh-to-vercel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
- name: Build with Hugo on master
working-directory: exampleSite
run: |
git clone https://github.com/StefMa/hugo-fresh themes/hugo-fresh
hugo \
--minify \
--baseURL https://hugo-fresh.vercel.app/
Expand All @@ -32,5 +31,6 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
vercel-project-name: hugo-fresh
vercel-args: '--prod'
working-directory: ./exampleSite/public

0 comments on commit 814f747

Please sign in to comment.