Update deploy.yml #39
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] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Dart | |
uses: dart-lang/setup-dart@v1 | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Cache Dart packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pub- | |
- name: Install dependencies | |
run: dart pub get | |
- name: Build site | |
run: dart run bin/main.dart | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: build | |
retention-days: 7 | |
- name: Upload PR preview artifact | |
if: github.event_name == 'pull_request' | |
uses: actions/upload-artifact@v3 | |
with: | |
path: build | |
name: pr-preview-build | |
retention-days: 1 | |
deploy-production: | |
needs: build | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
permissions: | |
pages: write | |
id-token: write | |
contents: read | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
timeout: 600000 | |
deploy-preview: | |
needs: build | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
permissions: | |
pages: write | |
id-token: write | |
pull-requests: write | |
deployments: write | |
statuses: write | |
contents: read | |
concurrency: | |
group: "pages-pr-${{ github.event.pull_request.number }}" | |
cancel-in-progress: true | |
environment: | |
name: preview | |
url: ${{ steps.deployment.outputs.preview_url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download PR preview artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: pr-preview-build | |
path: build | |
- name: Deploy preview | |
uses: rossjrw/pr-preview-action@v1 | |
with: | |
dir: ./build/ | |
action: auto |