Migrate to caisy.io (WIP) #66
Workflow file for this run
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: Build and deploy new PR site preview | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
branches: [main] | |
workflow_dispatch: | |
permissions: | |
pull-requests: write # GitHub Actions bot permissions | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Comment on PR | |
uses: hasura/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "Starting deployment of preview ⏳..." | |
- name: Checkout and setup node | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: npm | |
cache-dependency-path: "./package-lock.json" | |
- name: Create dotenv | |
run: | | |
echo "SITE_URL=https://dallyh.github.io/" >> .env | |
echo "SITE_BASE=/deploy-previews/${{ github.event.repository.name }}/${{ github.event.pull_request.number }}/" >> .env | |
- name: Install Node dependencies | |
run: npm install | |
- name: Build the site | |
run: npm run build | |
- name: Upload site artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: site | |
path: ./dist/ | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: pull-request-preview | |
url: https://dallyh.github.io/deploy-previews/${{ github.event.repository.name }}/${{ github.event.pull_request.number }}/ | |
steps: | |
- name: Download the artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: site | |
path: ./dist/ | |
- name: Upload files to GitHub Pages | |
uses: cpina/[email protected] | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | |
with: | |
source-directory: "./dist/" | |
destination-github-username: ${{ github.actor }} | |
destination-repository-name: "deploy-previews" | |
target-branch: main | |
target-directory: "${{ github.event.repository.name }}/${{ github.event.pull_request.number }}" | |
- name: Output the URL | |
run: echo "https://dallyh.github.io/deploy-previews/${{ github.event.repository.name }}/${{ github.event.pull_request.number }}/" | |
- name: Update comment | |
uses: hasura/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ https://dallyh.github.io/deploy-previews/${{ github.event.repository.name }}/${{ github.event.pull_request.number }}/ ✨\n\nPlease note that it may take a few seconds for GitHub Pages to build and deploy." |