mirror of
https://github.com/djkotowski/personal-website.git
synced 2026-09-12 13:30:40 -05:00
A merge to main could break the app even though the PR check ran ci-test separately; deploy previously fired on push regardless of CI outcome. Trigger deploy via workflow_run on ci-test completion instead, and skip the build job unless ci-test concluded success, so a broken main no longer publishes to Pages.
61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
name: deploy
|
|
run-name: "${{ github.actor }} is deploying ${{ github.event.workflow_run.head_sha }}"
|
|
on:
|
|
workflow_run:
|
|
workflows: ['ci-test']
|
|
types: [completed]
|
|
branches: ['main']
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: false
|
|
jobs:
|
|
build:
|
|
if: github.event.workflow_run.conclusion == 'success'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
ref: ${{ github.event.workflow_run.head_sha }}
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v5
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version-file: '.tool-versions'
|
|
cache: 'pnpm'
|
|
- name: Install Dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Build solution
|
|
run: pnpm build
|
|
- name: Archive artifacts
|
|
uses: actions/[email protected]
|
|
with:
|
|
path: dist/
|
|
deploy:
|
|
needs: build
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
contents: write
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
ref: ${{ github.event.workflow_run.head_sha }}
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v5
|
|
- name: Tag deploy
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
sha="${{ github.event.workflow_run.head_sha }}"
|
|
tag="deploy-$(date +%Y-%m-%d)-${sha::7}"
|
|
git tag "$tag" "$sha"
|
|
git push origin "$tag"
|