Update deploy.yml #5
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: 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 Dart | |
uses: dart-lang/setup-dart@v1 | |
- name: Install dependencies | |
run: dart pub get | |
- name: Build site | |
run: dart run bin/main.dart | |
- name: Check build directory before setup | |
run: | | |
echo "Current directory:" | |
pwd | |
echo "Directory contents:" | |
ls -la | |
echo "Build directory contents:" | |
ls -la build || echo "Build directory not found" | |
- 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: build | |
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: Check build directory before production upload | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
echo "Current directory:" | |
pwd | |
echo "Directory contents:" | |
ls -la | |
echo "Build directory contents:" | |
ls -la build || echo "Build directory not found" | |
- name: Upload Production Artifact | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: build | |
if-no-files-found: error | |
- name: List artifacts after upload | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
echo "Artifacts in runner:" | |
find /home/runner/work -name "github-pages*" | |
- name: Deploy Production | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/deploy-pages@v3 | |
with: | |
artifact_name: github-pages |