Create deploy.yml #1
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: Deploy Catalyst Voices Updates | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
pages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload Preview Artifact | |
if: github.event_name == 'pull_request' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: github-pages | |
path: dist | |
retention-days: 1 | |
- name: Deploy Preview | |
if: github.event_name == 'pull_request' | |
uses: actions/deploy-pages@v3 | |
with: | |
preview: true | |
artifact_name: github-pages | |
- name: Add Preview URL Comment | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const preview_url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-preview/pr-${context.issue.number}`; | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `🚀 Preview deployment is ready!\nURL: ${preview_url}` | |
}) | |
- name: Upload Production Artifact | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: dist | |
- name: Deploy Production | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/deploy-pages@v3 |